关闭UIImagePickerController [英] Dismiss UIImagePickerController

查看:158
本文介绍了关闭UIImagePickerController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了解除UIImagePickerController的所有变种,但没有运气。我做错了什么。

I have tried every variation of dismissing a UIImagePickerController with out any luck. What am i doing wrong.

- (IBAction)choosePhoto
{
    self.picker = [[UIImagePickerController alloc] init];
    self.picker.delegate = self;
    self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentModalViewController:self.picker animated:YES];

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)imagePicker
{
    NSLog(@"dismiss image picker");
    [self dismissModalViewControllerAnimated:NO];
    [[self.picker parentViewController] dismissModalViewControllerAnimated:NO];
    [self.presentedViewController dismissModalViewControllerAnimated:NO];
    [self.presentingViewController dismissModalViewControllerAnimated:NO];
     // And every other way i could think of
}

- (void)imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    .. same stuff here
}

我试图提供选择器从父,祖父母,navigationController和根控制器,没有任何作用。我做什么我不能解雇ImagePickerController。

I have tried to present the picker from the parent, grandparent, navigationController and root controller and nothing works. What ever i do i cant dismiss the ImagePickerController.

请注意每次调用日志语句。

Please note the log statement gets called every time.

干杯

推荐答案

试试这一行。它可能适合你。

[self.picker dismissModalViewControllerAnimated:NO];

对于 iOS 6 以及稍后使用此

[self.picker dismissViewControllerAnimated:NO completion:nil];

也可以使用此代码来展示您的选择器控制器

Also use this code to present your picker controller

if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]){
    [self presentViewController:self.picker animated:YES completion:nil];
} else {
    //To target iOS 5.0
    [self presentModalViewController:self.picker animated:YES];
}

这篇关于关闭UIImagePickerController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆