フォトライブラリから写真を読み込んで、指定したUIImageViewに挿入できるようにするアプリケーションを作成しようとしています。私はこれを私のインターフェイスでUIImageViewsの1つで動作させることができましたが、2番目のUIImageViewに割り当てることができません。フォトライブラリから複数の画像をアプリケーションにインポートする
誰かが私が間違っていることを教えてもらえれば、私は非常に感謝します!ありがとう! SBB
ここでは私のコードです:
@implementation FlipBook2ViewController
- (IBAction)selectExistingPicture {
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *picker =
[[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsImageEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Error accessing photo library"
message:@"Device does not support a photo library"
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
- (IBAction)selectExistingPicture2 {
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *picker =
[[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsImageEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Error accessing photo library"
message:@"Device does not support a photo library"
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
#pragma mark -
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo {
imageView.image = image;
[picker dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissModalViewControllerAnimated:YES];
}
アドバイスありがとうございます!私はそれをテストします! – Sunny
うーん.. ..動作していないようです。私は2つのボタンと2つのImageViewを持っています。それぞれのボタンを押したときにフォトライブラリから選択した画像が取り込まれるはずです。 – Sunny
どのような変更を行いましたか? –