Can't add self as subview
来源:互联网 发布:apple好玩的软件 编辑:程序博客网 时间:2024/05/22 01:31
在最近的项目开发过程中,发现当从A控制器像B控制push,当我们连续快速(时间间隔在0.5S内,也就是PUSH前一个事件的PUSH动画还没结束之前)点击两次这个按钮的时候,就会导致这个按钮连续响应了两次事件,同时推出了两个控制器A1、A2(这两个控制器都是A类型的),当我们再次点击A1(A2)返回的时候,点击第一次返回会是黑屏,再次点击A2(A1)返回的时候,就会报以下这个崩溃
Can't add self as subview
最后找到处理的方法是 在自定义的navigationcontroller 实现里加上如下代码 就OK了
@property (nonatomic,assign)BOOL currentAnimating;
- (void) pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if(_currentAnimating)
{
return;
}
else if(animated)
{
_currentAnimating =YES;
}
[superpushViewController:viewController animated:animated];
}
- (UIViewController *) popViewControllerAnimated:(BOOL)animated
{
if(_currentAnimating)
{
return nil;
}
else if(animated)
{
_currentAnimating =YES;
}
return [superpopViewControllerAnimated:animated];
}
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
_currentAnimating =NO;
}
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[selftransitionCoordinator] notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context)
{
if([context isCancelled])
{
UIViewController *fromViewController = [contextviewControllerForKey:UITransitionContextFromViewControllerKey];
[selfnavigationController:navigationController willShowViewController:fromViewController animated:animated];
if([self respondsToSelector:@selector(navigationController:didShowViewController:animated:)])
{
NSTimeInterval animationCompletion = [context transitionDuration] * [context percentComplete];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (uint64_t)animationCompletion *NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[selfnavigationController:navigationController didShowViewController:fromViewController animated:animated];
});
}
}
}];
}
- Can't add self as subview
- Can't add self as subview
- Can't add self as subview
- Can't add self as subview
- 错误:Can't add self as subview
- Can't add self as subview 的崩溃
- iOS app error - Can't add self as subview
- iOS7 Can't add self as subview 的崩溃
- ios 'Can't add self as subview'崩溃日志详解
- 'Can't add self as subview'崩溃日志详解
- iOS bug解决 Can't add self as subview
- Can't add self as subview crash的出现的可能及解决方法
- phone - iOS app error - Can't add self as subview - Stack Overflow
- Can't find (or read) directory to add to classloader: ../../../contrib/extraction/lib (resolved as:
- ubuntu can't add add-apt-
- can't get git rev, you should add git to system path or just input test value, such as 'testTinkerId
- you can’t add a second ‘$and’
- unity提示can't add script解决办法
- Eclipse 使用 Link 方式进行插件的安装
- 给定点的json文件,绘制路径
- ShaderLab内置值
- 行内元素与块级元素比较全面的区别和转换
- 2588: Spoj 10628. Count on a tree 主席树+LCA
- Can't add self as subview
- erlang 系统工具
- 在Window平台下安装xgboost的Python版本
- 即点即改
- git如何创建远程仓库
- activity跳转activity不销毁
- nodejs小记之手动搭建express框架
- HTML5-炫丽的时钟效果Canvas绘图与动画
- linux 下使用log4cxx服务