在我的一个UINavigationController
观点中,用户可以使用“添加”按钮从相册中选择照片UIImagePickerController
。当用户选择所需的照片时,我想让他AddPhotoViewController
查看他可以添加标题和描述的位置,而不是他可以按“保存”按钮保存数据、关闭AddPhotoViewController
视图并返回上一个UINavigationController
视图。到目前为止,我只能推送AddPhotoViewController
视图,不能将其作为模态视图。我就是这样做的:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
AddPhotoViewController *apvc = [self.storyboard instantiateViewControllerWithIdentifier:@"addPhoto"];
apvc.info = info;
[self.navigationController pushViewController:apvc animated:YES];
[self dismissViewControllerAnimated:YES completion:nil];
}
上面的代码工作正常,但我想添加 AddPhotoViewController 作为 modal view 。我想使用presentModalViewController:animated:
,但它在 iOS 6.0 中已贬值。比我试过的:
[self presentViewController:apvc animated:YES completion:nil];
代替:
[self.navigationController pushViewController:apvc animated:YES];
但我收到此错误:
Warning: Attempt to present <AddPhotoViewController: 0x1e183fc0> on <UINavigationController: 0x1d594a70> whose view is not in the window hierarchy!
UINavigationController
在我关闭视图后,有什么方法可以在视图顶部添加模态UIImagePickerController
视图吗?