我有一个应用程序,允许用户将图片添加到日志中。 如果用户选择从库中添加,一切都很好,但如果用户选择采取 用相机拍摄的照片有问题:
当相机模态视图动画化时,我要么拍照并点击“使用”,要么点击“取消”按钮,调用dismissModalViewAnimated时所在的 View 将从其 super View 中删除。
有人对此有解释吗?
这是我用来呈现模态视图 Controller 的代码
pickerCont = [[UIImagePickerController alloc] init];
pickerCont.delegate = self;
pickerCont.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:pickerCont animated:YES];
这就是我用来驳回它的方法:
[self dismissModalViewControllerAnimated:YES]
最佳答案
实际上你正在驳回parentview。这里self代表parentView
使用 UIImagePickerController 的 delegate 来关闭 UIImagePickerController
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
//get picked image here
[pickerCont dismissModalViewControllerAnimated:YES]
}
关于iphone - missModalViewAnimated实际上删除了父 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12420659/