我試圖做一些簡單:從圖像選擇器返回時如何更改視圖控制器?
- 從控制器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