Unbalanced calls to begin/end appearance transitions for XXX

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Unbalanced calls to begin/end appearance transitions for XXX相关的知识,希望对你有一定的参考价值。

出现此crash,基本是因为子视图控制器的切换,也就是这句代码:

transitionFromViewController: toViewController:

且基本是因为fromViewController与toViewController是同一个ViewController,造成Unbalanced

,大多场景是因为加入了segmentControl,控制子视图的切换.以下是示例代码:

- (void)itemChange:(UISegmentedControl *)sender {

 

    switch (sender.selectedSegmentIndex) {

            case 0:

 

        {

            [self replaceFromOldViewController:currentVC toNewViewController:taskVC];

        }

            

            break;

            case 1:

        {

            [self replaceFromOldViewController:currentVC toNewViewController:classVC];

        }

            break;

            case 2:

        {

            [self replaceFromOldViewController:currentVC toNewViewController:weakVC];

        }

            break;

            

        default:

            break;

    }

}

 

- (void)replaceFromOldViewController:(UIViewController *)oldVc toNewViewController:(UIViewController *)newVc{

    if (currentVC == newVc) {//解决上述问题的判断

        return;

    }

    if (newVc != nil) {

        [self addChildViewController:newVc];

        [self transitionFromViewController:oldVc toViewController:newVc duration:0.1 options:UIViewAnimationOptionTransitionCrossDissolve animations:nil completion:^(BOOL finished) {

            if (finished) {

                [newVc didMoveToParentViewController:self];

                [oldVc willMoveToParentViewController:nil];

                [oldVc removeFromParentViewController];

                currentVC = newVc;

            }else{

                currentVC = oldVc;

            }

        }];

 

    }

}

 

以上是关于Unbalanced calls to begin/end appearance transitions for XXX的主要内容,如果未能解决你的问题,请参考以下文章

Possible unbalanced tuple unpacking with sequence

Possible unbalanced tuple unpacking with sequence

解析 Array.prototype.slice.call 的作用

agc045_b 01 Unbalanced

CompositeDisposable.clear 导致 OkHttp 抛出 java.lang.IllegalStateException: Unbalanced enter/exit

sql 调用从特定dnis桥接扩展 - 此特定查询为cal调用dnis,ani,扩展名,call_begin_datetime和音频