我试图做一些简单:从图像选择器返回时如何更改视图控制器?
- 从控制器MAViewControllerMenu我可以选择一个现有的图片
- 选择后,我在返回到MAViewControllerMenu返回MAViewControllerMenu通过驳回选择器视图
- 权,我想切换到另一个控制器MAViewControllerPictureDisplay,我可以在其中查看在imageView中选择的图像。
但是,它不会把我带到下一个视图。
下面是MAViewControllerMenu代码
MAViewControllerPictureDisplay* imageControllerView;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//load next page
imageControllerView = [[self storyboard] instantiateViewControllerWithIdentifier:@"chosenImageController"];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
image = [info objectForKey:UIImagePickerControllerOriginalImage];//Take image from picker
imageControllerView.image = image;//set it for the next controller's property
[self dismissViewControllerAnimated:YES completion:^{
[self.presentingViewController presentModalViewController:imageControllerView
animated:YES];
}];
//NEXT LINE DOESNT WORK
[self presentViewController:imageControllerView animated:YES completion:nil];//THAT DOESNT WORK
}
然而,我在我的第一个控制器中设置的按钮时,在一个点击运行该线之上通过函数如下,和一个不带我去下一个控制器:
- (IBAction)movetonext{
[self presentViewController:imageControllerView animated:YES completion:nil];
}
我错过了什么?为什么在点击按钮时调用它,但在没有触摸事件的情况下调用时,在选择图片后不起作用?
感谢
它导致它崩溃与NSException –
你是对的,我很抱歉,这只适用于UINavigationController,只是自己检查.. – MCMatan