2016-10-01 10 views
1

私は、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を使用した場合

おかげ

+0

これを一度ご覧ください。http://stackoverflow.com/questions/38236723/ios-10-error-access-private-when-using-uiimagepickercontroller –

+0

新しいサンプルプロジェクトで書いたように、コードをコピーして貼り付けました。作成されましたが、機能します。あなたの説明なしで追加したことの1つは、info.plistプライバシー写真ライブラリの使用でした。 – boraseoksoon

+0

こんにちは、info.plistをチェックして、プライバシー設定が既にあります。私は問題を見つけるように見えないので、本当に奇妙です。 – ORStudios

答えて

1

は、「プライバシーフォトライブラリの使用」のための鍵があることを確認し、プロジェクトのInfo.plistを確認してください。

あなたのコードは正しいです、多分問題はinfo.plistです。

+0

こんにちは、すでにそこにあった、Ipadを再起動した後、すべてがうまくいったからです。 – ORStudios

0

私は同様の問題がありました。イメージが選択されるとすぐにピッカーがガベージコレクションされていたので、デリゲートは呼び出されませんでした。

ピッカーを提示する前にピッカーへの強い参照が行われていることを確認する必要がありました。

これが完了したら、正常に機能しました。

関連する問題