问题驳回和重新presenting的UIImagePickerController相机iOS8.4 [英] Problems dismissing and representing UIImagePickerController camera iOS8.4

查看:126
本文介绍了问题驳回和重新presenting的UIImagePickerController相机iOS8.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

修改问题从头开始恢复。

我有一个的ViewController A 其中有一个导航栏按钮,presents一个的UIImagePickerController UIImagePickerControllerSourceTypeCamera ,我们会打电话给这个ViewController中的。在 didFinishPickingMediaWithInfo:方法的 A ,然后我present的ViewController C

现在的问题从这里开始。当我终于到达 C ,我们可以看到该视图栈显然是:


  

A -modal-> -modal-> C


C ,然后我有一个后退按钮$ P $应该带我回的在导航栏上psent。然而,由于是一个的UIImagePickerController,我不能再使用它,它必须被驳回。因此,要做到这一点,我现在有对于后退按钮下面的方法执行 C

   - (IBAction为)backOnPost:(*的UIBarButtonItem)发件人
{
    [self.view endEditing:YES];    UINavigationController的* LogControl = [self.storyboard instantiateViewControllerWithIdentifier:@LogControl];
    RGLogViewController *日志查看=(RGLogViewController *)LogControl.topViewController;    [UIView的animateWithDuration:0.25动画:^ {
         。自presentingViewController.view.alpha = 0;
        [自presentingViewController dismissViewControllerAnimated:NO完成:零]
        [自presentingViewController presentingViewController dismissViewControllerAnimated:NO完成:无]
    }完成:^(BOOL完){
        [日志查看setBoolBackPushed]
    }];
}

以上code工作在它被解雇的 C 把我带回到为 A 。但是,你仍然可以看到,因为从两ViewControllers解雇有点黑筛选的过渡。您可以在完成块看到 [日志查看setBoolBackPushed]; ,这是设置一个静态布尔变量设置为true,这样的的 A 的<开始code> viewWillAppear中: presents一个新的的UIImagePickerController 立即 - 方法是这样的:

   - (无效)viewWillAppear中:(BOOL)动画
{
    的NSLog(@HERES postBackButtonPushed:%HHD,postBackButtonPushed);    如果(postBackButtonPushed ==真)
    {
        self.view.hidden = YES;
        self.navigationController.navigationBar.hidden = YES;
        self.tabBarController.tabBar.hidden = YES;        *的UIImagePickerController = imagePicker [的UIImagePickerController页头]初始化];
        imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagePicker.delegate =自我;
        [自presentViewController:imagePicker动画:NO完成:^ {}];
    }

这是目前我如何收到以下预期的效果:从进入的 A 以相机(),为 C ,然后回到一个新的相机,这是我们新的。做到这一点瓦特/近乎完美的无缝的转变。<​​/ P>

林仍然有能够稍微看到的过渡问题。另一个问题是定时。解聘和presenting ViewControllers的这种合作需要更多的时间比我想它。这几乎是即时的,但我想更好的东西。我应该怎么做,我做错了什么?


解决方案

我相信这会为你工作。
做的!

  [自presentingViewController dismissViewControllerAnimated:NO完成:^ {
               [自presentingViewController dismissViewControllerAnimated:是的完成:^ {               }];
           }];

而不是

  [自presentingViewController presentingViewController dismissViewControllerAnimated:NO完成:无]

EDIT Problem reinstated from scratch.

I have a ViewController A which has a Navigation Bar Button which presents an UIImagePickerController of sourcetype UIImagePickerControllerSourceTypeCamera, we'll call this ViewController B. In the didFinishPickingMediaWithInfo: method of A, I then present ViewController C.

The problem now starts here. When I finally reach C, we can see that view stack is clearly:

A -modal-> B -modal-> C

From C I then have a "Back" button present on the navigation bar which should take me back to B. However, since B is an UIImagePickerController, I cannot reuse it and it must be dismissed. So, to make this happen, I currently have the following method executing for that "Back" button on C:

- (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];
    }];
}

The above code works in that it takes me back to A by dismissing B and C. However, you can still see the transition because of a bit of "black-screening" from the dismissal of the two ViewControllers. You can see in the completion block [logView setBoolBackPushed];, this sets a static BOOL variable to true so that the beginning of A's viewWillAppear: presents a new UIImagePickerController immediately - the method looks like this:

- (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:^{}];
    }

This is currently how I am getting the following desired effect: Go from A to the camera (B), to C and then back to a new camera which is our new B. This is achieved w/ almost perfect seamless transitions.

Im still having problems with being able to slightly see the transitions. Another problem is the timing. This collaboration of dismissing and presenting ViewControllers takes more time than I would like it to. It's almost instantaneous, but I would like something better. What should I do and am I doing something wrong?

解决方案

I believe this will work for you. Do!

 [self.presentingViewController dismissViewControllerAnimated:NO completion:^{
               [self.presentingViewController dismissViewControllerAnimated:YES completion:^{

               }];
           }];

Instead of

 [self.presentingViewController.presentingViewController dismissViewControllerAnimated:NO completion:nil];

这篇关于问题驳回和重新presenting的UIImagePickerController相机iOS8.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆