私は、IPadを使用している間に画像を選択するために以下の設定を行っています。問題は、デリゲートが呼び出されることはないということです。私はブレークポイントを入れましたが、決して活性化されません。IOS 10 UIImagePickerControllerデリゲートが呼び出されていない
.H
@interface HomeViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
.M
- (IBAction)loadImage:(id)sender {
self.imagePickerController = [[UIImagePickerController alloc] init];
self.imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
self.imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.imagePickerController.allowsEditing = NO;
self.imagePickerController.delegate = self;
[self presentViewController:self.imagePickerController animated:YES completion:nil];
}
// This method is called when an image has been chosen from the library or taken from the camera.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
//You can retrieve the actual UIImage
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
//Or you can get the image url from AssetsLibrary
NSURL *path = [info valueForKey:UIImagePickerControllerReferenceURL];
[picker dismissViewControllerAnimated:YES completion:nil];
}
誰もが問題を見ることができますか?プロジェクトを実行するためにXcode8を使用した場合
おかげ
これを一度ご覧ください。http://stackoverflow.com/questions/38236723/ios-10-error-access-private-when-using-uiimagepickercontroller –
新しいサンプルプロジェクトで書いたように、コードをコピーして貼り付けました。作成されましたが、機能します。あなたの説明なしで追加したことの1つは、info.plistプライバシー写真ライブラリの使用でした。 – boraseoksoon
こんにちは、info.plistをチェックして、プライバシー設定が既にあります。私は問題を見つけるように見えないので、本当に奇妙です。 – ORStudios