这是一个iPhone应用程序,我有一个助手视图,它总是在窗口顶部(可以扩展和最小化)。视图内部有几个按钮,允许我在捕获图像,捕获视频和录制音频之间切换。在app delegate中,它看起来像:
[self.window addSubview:assistantFloatingViewController.view];
[self.window makeKeyAndVisible];
self.window.frame = [UIScreen mainScreen].bounds;
然后在助理视图中单击捕获图像按钮时添加UIImagePickerController
:
- (void)presentImagePicker{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.mediaTypes = @[(__bridge NSString *) kUTTypeImage];
[self moveFromViewController:self.currentContentViewController ToViewController:imagePickerController];
self.currentContentViewController = imagePickerController;
}
- (void)moveFromViewController:(UIViewController *)fromVC ToViewController:(UIViewController *)toVC {
[fromVC willMoveToParentViewController:nil];
[self addChildViewController:toVC];
[fromVC.view removeFromSuperview];
[fromVC removeFromParentViewController];
[self.view addSubview:toVC.view];
[toVC.view alignToView:self.containerView];
[toVC didMoveToParentViewController:self];
self.currentContentViewController = toVC;
}
问题出在我拍摄图像后,无法点按“重拍”和“用户照片”按钮(无响应)。
我在这里做错了什么?任何帮助将不胜感激!
答案 0 :(得分:0)
替换代码的最后两行
[self moveFromViewController:self.currentContentViewController ToViewController:imagePickerController];
self.currentContentViewController = imagePickerController;
有了这个,
[self presentViewController:imgPicker animated:YES completion:^{
// Your code
}];