[bug原因与修复] Unbalanced calls to begin/end appearance transitions for...
来源:互联网 发布:app软件推广 编辑:程序博客网 时间:2024/05/18 22:42
网上找了一圈,大部分原因还是第一种,第二种找了以前没见人提过。
这个 Bug 会在你使用了 iOS 5 的新特性去管理 UIViewController 的时候出现。
Bug 的现象是 View 变成纯白,打出 Unbalanced calls to begin/end appearance transitions for 的 Log,出现有两种原因
第一个原因:
就是 self.currentView,和你要transitionTo 的界面是一样的
说白了从自己到自己不叫Transition
代码解决就是在 [self transitionFromViewController: 这句话前面加上
if([self.childViewControllers objectAtIndex:showSegmentNum] == self.currentViewController){ return; }
——分割线——
第二个原因:
动画原因,一个动画还没执行完,第二个动画又要执行,就会出错。
拿代码来说
[self transitionFromViewController:self.currentViewController toViewController:[self.childViewControllers objectAtIndex:showSegmentNum] duration:0.0 options:UIViewAnimationOptionTransitionNone animations:^{ //动画块 } completion:^(BOOL finished) { //结束块 }];
代码上是这样,在你执行一次[self transitionFromViewController...]之后,一次transition结束之后会执行结束块代码。
但是如果你在执行了[self transitionFromViewController...]这个方法之后,还在结束块被调用(就是transition正式结束)之前又调用了一次[self transitionFromViewController...]这个方法,就会出现白屏打Log,
解决方法:
@implementation ...
@implementation之后加入一个
BOOL transiting;
在[self transitionFromViewController...]之前加上
</pre></div><pre name="code" class="objc"> if(transiting){ return; } transiting = YES;
在这个结束块的时候,置
transiting = NO;
代码总体:
BOOL transiting;-(void)showSegmentView:(NSUInteger)showSegmentNum{ if(transiting){ return; } transiting = YES; [self transitionFromViewController:self.currentViewController toViewController:[self.childViewControllers objectAtIndex:showSegmentNum] duration:0.0 options:UIViewAnimationOptionTransitionNone animations:^{ //动画快 } completion:^(BOOL finished) { //结束块 transiting = NO; }]; self.currentViewController = [self.childViewControllers objectAtIndex:showSegmentNum]; self.currentViewController.view.frame = self.baseRect;}
OVER.
0 0
- [bug原因与修复] Unbalanced calls to begin/end appearance transitions for...
- Unbalanced calls to begin/end appearance transitions for <uivewcontroller>
- Unbalanced calls to begin/end appearance transitions for
- Unbalanced calls to begin/end appearance transitions for <UIVewController XX>
- Unbalanced calls to begin/end appearance transitions for <uivewcontroller>
- Unbalanced calls to begin/end appearance transitions for 解决方法
- Unbalanced calls to begin/end appearance transitions for
- Unbalanced calls to begin/end appearance transitions for
- Unbalanced calls to begin/end appearance transitions for
- Unbalanced calls to begin/end appearance transitions for <UIViewController>
- 提示:Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x73b07a0>.
- unbalanced calls to begin/end appearance transitions for uiviewcontroller的解决方法
- unbalanced calls to begin/end appearance transitions for uiviewcontroller的解决方法
- unbalanced calls to begin/end appearance transitions for uiviewcontroller的解决方法
- unbalanced calls to begin/end appearance transitions for uiviewcontroller的解决方法
- Unbalanced calls to begin/end appearance transitions for <AllInfoViewController: 0x15627e00>.
- Unbalanced calls to begin/end appearance transitions for <IDOOrderHomeViewController: 0x8da2960>.
- Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0xac500c0>.
- 传入xml,在树表中递归,再归组加入其他表
- 查找学生信息(map使用)
- iOS应用如何实现64位的支持
- [Python]网络爬虫(三):异常的处理和HTTP状态码的分类
- document.getElementById('tksm1')
- [bug原因与修复] Unbalanced calls to begin/end appearance transitions for...
- Zend_Db
- C/C++运行时库 解释
- C:\Users\用户名\AppData\Roaming里面的文件可以删除吗?
- jQuery ui 拖放函数
- 高效率的取幂运算
- 6个APP应用市场运营推广方法
- P51 第二章 第9题
- Python sys.path详细介绍