ビューにボタンがある iOS アプリを作成しています。そのボタンをクリックすると、カメラまたはギャラリーから画像を選択するオプションを含むアクション シートが表示されます。画像が選択されたら、手動でセグエを呼び出して別のビューに渡す必要があります。イメージ ピッカーが表示され、セグエ コードの準備が実行されますが、セグエは表示されません。エラーはなく、すべての識別子などを確認しました。コードは次のとおりです。
-(IBAction)showButtonClicked:(id)sender {
UIActionSheet *photoActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose from Library", nil];
photoActionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[photoActionSheet showInView:self.tabBarController.tabBar];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
case 0:
{
[self dismissModalViewControllerAnimated:YES];
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
break;
}
case 1:
{
[self dismissModalViewControllerAnimated:YES];
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
break;
}
default:
break;
}
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"goToPhotoDetails"]){
FostoPhotoDetailsViewController *photoDetails = (FostoPhotoDetailsViewController *)segue.destinationViewController;
photoDetails.imageView.image = self.buttonImage1;
}
}
- (void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
self.buttonImage1 = image;
//FostoPhotoDetailsViewController *photoDetails = [[FostoPhotoDetailsViewController alloc] init];
//photoDetails.imageView.image = image;
[self dismissModalViewControllerAnimated:NO];
NSLog(@"Test");
[self performSegueWithIdentifier:@"goToPhotoDetails" sender:self];
}