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;

}

}];

}

}

时间: 2024-10-13 22:52:29

Unbalanced calls to begin/end appearance transitions for XXX的相关文章

(转)unbalanced calls to begin/end appearance transitions for uiviewcontroller的解决方法

iOS5 UIViewController加入了管理UIViewController的功能,就像管理subview一样方便.这儿有一博文介绍得很清楚.我在项目中用到了它,方便view的切换.下面的代码有一种fade in/out的效果. [self transitionFromViewController:_currentVC toViewController:newVC duration:0.5 options:UIViewAnimationOptionTransitionCrossDisso

Unbalanced calls to begin/end appearance transitions for <IDOOrderHomeViewController: 0x8da2960>.

自定义TabBarController Push下一级Controller时 会报这样的错误:Unbalanced calls to begin/end appearance transitions for <UIVIewController>. 网上的一些回答,都说是动画引起的,解决方法就是,加一个BOOL型的变量,检查是否在做动画. if (transiting) { return; } transiting = YES; [self transitionFromViewControlle

自定义TabBarController报错 - Unbalanced calls to begin/end appearance transitions for &lt;&gt;

自定义了TabBarController 之后必须实现以下方法才能避免报错 -(void)viewWillAppear:(BOOL)animated { [self.selectedViewController beginAppearanceTransition: YES animated: animated]; } -(void) viewDidAppear:(BOOL)animated { [self.selectedViewController endAppearanceTransitio

iOS BUG: Unbalanced calls to begin/end appearance transitions for &lt;XXXViewController: 0x7fcea3730650&gt;.

自定义TabBarController Push下一级Controller时 会报这样的错误:Unbalanced calls to begin/end appearance transitions for <XXXViewController: 0x7fcea3730650>. 网上的一些回答,都说是动画引起的,解决方法就是,加一个BOOL型的变量,检查是否在做动画. if (transiting) {        return;    }    transiting = YES;    

Unbalanced calls to begin/end appearance transitions for XXXX

出现此问题是因为前一个动画并没有被执行完, 你又开始执行下一个动画.你仔细找找做动画之前有没有其他关于动画的操作. 开始看到这个答案,我自作聪明的不就是动画冲突吗?然后把最后的那个动画(pushviewController animated : )改为No,就以为好了,然而并不弹,沉下心来找把.最终还是让我找到了. 我这个nav会连续push两个窗体,第一个还没push完呢,我就开始push第二个.然后把第一个的animated:NO,就OK了. 还有这个bug只有在真机上会出现,模拟器不会.

Unbalanced calls to begin/end appearance transitio

Unbalanced calls to begin/end appearance transition for .... 当几乎同时将两个视图控制器push到当前的导航控制器栈中时,或者同时pop两个不同的视图控制器,就会出现不确定的结果.所以我们应该确保同一时间,对同一个导航控制器栈只有一个操作,即便当前的视图控制器正在动画过程中,也不应该再去push或pop一个新的视图控制器.所以最后我们把web活动的数据请求放到了viewDidAppear里面,并做了些处理,这样问题就解决了.

UITabBarController未呈现时present另一个ViewController会发生什么?

一次给了下面两条警告(精彩吧): Presenting view controllers on detached view controllers is discouraged Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x7fc046131d70>. 解决办法,dispatch_after 延迟present就好了.

iOS开发——错误总结篇&amp;开发中常见错误和警告总结(三十三)

开发中常见错误和警告总结(三十三) 动画冲突 错误: Unbalanced calls to begin/end appearance transitions for <uivewcontroller> 解决方法1:去掉动画 解决方法2:监听当前view的动画是否完成 解决方法就是,加一个BOOL型的变量,检查是否在做动画. 1 2 if (transiting) { 3 return; 4 } 5 transiting = YES; 6 [self transitionFromViewCon

第三方苹果开发库之ASIHTTPRequest(翻译版)

本文转载至 http://www.cnblogs.com/daguo/archive/2012/08/03/2622090.html 来自:http://www.dreamingwish.com/dream-2011/apples-third-party-development-libraries-asihttprequest.html 第三方苹果开发库之ASIHTTPRequest ASIHttpRequest库简介.配置和安装 ASIHttpRequest-创建和执行request ASIH