繁体   English   中英

从模态UIViewController呈现UIImagePickerController

[英]Presenting UIImagePickerController from modal UIViewController

我想要它,以便用户可以从他们的相册中选择一张照片进入imageview。 如果我使用push segue到具有执行动作的按钮的viewcontroller似乎工作正常,但当我将其更改为模态segue时,当我单击按钮运行该功能时没有任何反应。 究竟是什么原因造成的?

方法:

- (IBAction)choosePhotoFromAlbum:(id)sender {
    UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
    imgPicker.delegate = self;
    imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self.navigationController presentViewController:imgPicker animated:YES completion:nil];
}

您正尝试从导航控制器中显示它,但您的视图控制器是模态的。 更改

[self.navigationController presentViewController:imgPicker animated:YES completion:nil];

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

你试图从导航控制器中呈现它,但你的视图控制器是模态的。 所以写点

 [self presentViewController:YourImagePickerController animated:YES completion:nil];.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM