iphone - presentModalViewController :Animated is d

我将以下代码用于图像选择器。但是当我在模拟器中运行它时,我遇到了内存泄漏,并且我收到了关于 presentModalViewcontroller:animated 在 iOS6 中被弃用的警告。我也弃用了 dismissModalViewController:animated 。我正在使用 SDK 6.1。

ImagePicker 代码:

- (void)showAlbum:(id)sender { 
    imagePicker=[[UIImagePickerController alloc]init];
    imagePicker.delegate = self;
    imagePicker.allowsEditing =NO;
    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentModalViewController:imagePicker animated:YES];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    //release picker
    [picker dismissModalViewControllerAnimated:YES];
}

最佳答案

使用此行并检查:

[self presentViewController:imagePicker animated:YES completion:nil];

关于iphone - presentModalViewController :Animated is deprecated in ios6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15874094/

相关文章:

ios - 如何拦截 MKMapView 或 UIWebView 对象上的触摸事件?

objective-c - 无法使用 nil 模型创建 NSPersistentStoreCoord

objective-c - Xcode 4(和依赖项)的编译、构建或存档问题

objective-c - Swift 只读外部,读写内部属性

objective-c - 如何使用 performSelector :withObject:aft

ios - 以编程方式检索 iPhone 上的内存使用情况

iphone - CALayers 没有在其 UIView 的边界更改时调整大小。为什么?

objective-c - 按名称创建objective-c类实例?

objective-c - Swift 变量是原子的吗?

ios - 获取当前页面