[英]Presenting UIImagePickerController from modal ViewController
[英]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.