首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIImagePickerController摄像机iOS8.4的解译和表示问题

UIImagePickerController摄像机iOS8.4的解译和表示问题
EN

Stack Overflow用户
提问于 2015-07-14 01:32:45
回答 2查看 723关注 0票数 1

编辑问题从头开始恢复。

我有一个ViewController A,它有一个导航条按钮,它显示了源代码类型UIImagePickerControllerSourceTypeCameraUIImagePickerController,我们称之为ViewController B。在didFinishPickingMediaWithInfo:方法A中,我介绍了ViewController C

问题现在从这里开始。当我最终到达C时,我们可以清楚地看到视图堆栈是:

A -模态-> B --> C

在C中,导航栏上有一个" back“按钮,它将带我回到B。但是,由于B是一个UIImagePickerController,所以我不能重用它,因此必须取消它。因此,为了实现这一点,我目前在C上为"Back“按钮执行了以下方法

代码语言:javascript
复制
- (IBAction)backOnPost:(UIBarButtonItem *)sender
{
    [self.view endEditing:YES];

    UINavigationController *LogControl = [self.storyboard instantiateViewControllerWithIdentifier:@"LogControl"];
    RGLogViewController *logView = (RGLogViewController *)LogControl.topViewController;

    [UIView animateWithDuration:0.25 animations:^{
         self.presentingViewController.view.alpha = 0;
        [self.presentingViewController dismissViewControllerAnimated:NO completion:nil];
        [self.presentingViewController.presentingViewController dismissViewControllerAnimated:NO completion:nil];
    } completion:^(BOOL finished){
        [logView setBoolBackPushed];
    }];
}

上面的代码的工作原理是,通过取消B、和C,我回到了A。然而,您仍然可以看到过渡,因为有一点“黑色筛选”从两个ViewControllers的解雇。您可以在完成块[logView setBoolBackPushed];中看到,这将一个静态BOOL变量设置为true,以便A的viewWillAppear:的开头立即显示一个新的UIImagePickerController -该方法如下所示:

代码语言:javascript
复制
- (void)viewWillAppear:(BOOL)animated
{
    NSLog(@"HERES postBackButtonPushed:%hhd", postBackButtonPushed);

    if(postBackButtonPushed == true)
    {
        self.view.hidden = YES;
        self.navigationController.navigationBar.hidden = YES;
        self.tabBarController.tabBar.hidden = YES;

        UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
        imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagePicker.delegate = self;
        [self presentViewController:imagePicker animated:NO completion:^{}];
    }

这是目前我如何获得以下期望的效果:从A到照相机(B),到C,然后返回到新相机,这是我们新的B。这实现了几乎完美的无缝转换。

我仍然有问题,不能稍微看到过渡。另一个问题是时机问题。这种解散和展示ViewControllers的协作比我所希望的要花费更多的时间。几乎是瞬间的,但我想要更好的东西。我该怎么做,我是不是做错了什么?

EN

回答 2

Stack Overflow用户

发布于 2015-07-24 12:18:25

有一些可能导致您的问题的案例:

  1. 在A后面显示B,然后显示C,对于UX/UI和代码来说都是有点奇怪的行为。要么把B从A中推开,然后在B上呈现C,要么解散A,现在B,解散B,现在C。
  2. 有一些完成方法,但是您没有使用它们。您的代码显示,您为C调用dismissViewControllerAnimated两次,对ex调用B。你应该处理提交和拒绝订单。我认为iOS 8.2+或8.3+开始更有效地处理这些问题。如果有错误,它会在这个版本之后崩溃。
  3. 映像控制器在以不同的方式丢弃VC时,会导致此错误。为了前夫。在显示VC之前显示警告弹出也会导致崩溃。
票数 0
EN

Stack Overflow用户

发布于 2015-07-31 06:37:16

我相信这对你有用。做!

代码语言:javascript
复制
 [self.presentingViewController dismissViewControllerAnimated:NO completion:^{
               [RefrenceOfPreviousViewController dismissViewControllerAnimated:YES completion:^{

               }];
           }];

而不是

代码语言:javascript
复制
 [self.presentingViewController.presentingViewController dismissViewControllerAnimated:NO completion:nil];
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31396193

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档