【发布时间】:2014-12-19 17:43:46
【问题描述】:
我正在使用图像选择器拍摄照片并将其保存到数据库中。一旦我将它保存在数据库中,我会放置一个警告视图,说图像已保存,当我单击确定时,我需要关闭图像选择器视图并且我需要呈现另一个视图。
这就是我所拥有的
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self takePic];
}
-(void)takePic{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate =self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag==1) {
if (buttonIndex==0) {
UIImagePickerController *picker;
[picker dismissViewControllerAnimated:YES completion:NULL]; // here i am not able to dismiss the image picker view
Tab *vc=[self.storyboard instantiateViewControllerWithIdentifier:@"Tabbar"];
[self presentViewController:vc animated:YES completion:nil];
}
}
}
如果我没有在视图中放置 [self takepic],我可以关闭选择器视图。
我也试过了
[picker dismissViewControllerAnimated:YES completion:^{
[self presentViewController:vc animated:YES completion:NULL];
}];
但我无法关闭选择器视图。我收到警告:“警告:尝试显示不在窗口层次结构中的视图!”
谁能告诉我,如何关闭选择器视图
【问题讨论】:
标签: ios uiimagepickercontroller