私はこれについて多くのことを研究しました。ボタンに触れると、デバイスから画像を選択して画面に表示する必要があります。
しかし、ボタンがタッチ/押されると、アプリがクラッシュします。次のコード行からクラッシュします。
[self presentModalViewController:myPhotopicker animated:YES];
Xcode 4.2 を使用して iPad アプリを開発しています。テストには iPad 5.0 シミュレーターを使用しています。私のシステムは Mac OS X バージョン 10.6.8 で動作します。
ボタンが押されると、次の関数が呼び出されます。
-(IBAction)getPhoto:(id)sender
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
if (myPhotopicker==nil) { myPhotopicker = [[UIImagePickerController alloc] init];
myPhotopicker.delegate = self; }// create once!
myPhotopicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:myPhotopicker animated:YES];
} else {
NSString *str = @"Photo Album is not available!";
}
}