-(void) openPhotoLib:(id)sender {
[self dismissModalViewControllerAnimated:YES];
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[imagePicker setDelegate:self];
[self presentModalViewController:imagePicker animated:YES];
NSLog(@"openPhotoLib called");
}
私のView ControllerはUINavigationControllerとUIImagePickerDelegateのサブクラスですが、NSLog以外は何も起こりません。UIImagePickerController に関する洞察や経験がある人はいますか?
テストには主に iPhone を使用していることに注意してください。
解決策: UINavigationBarDelegate と UIImagePickerDelegate のみをサブクラス化する新しいクラスを作成します。そのクラスの viewDidAppear に、imagePicker をモーダルに表示するコードを配置します。メソッド内でこのクラスのインスタンスを作成し (別のクラス内で .h ファイルとすべてをインポートします)、そのクラスをモーダルに提示します。
↑持ち帰ります。モーダルアニメーションが本当の問題でした。これに別のクラス インスタンスを使用しようとすると、UIImagePicker のメソッドの実装が台無しになります。