iOS 10 中导航控制器出栈入栈连续操作存在的问题
来源:互联网 发布:mac自带修图软件怎么用 编辑:程序博客网 时间:2024/06/07 03:15
iOS 10 中导航控制器出栈入栈连续操作存在的问题
太阳火神的美丽人生 (http://blog.csdn.net/opengl_es)
本文遵循“署名-非商业用途-保持一致”创作公用协议
转载请保留此句:太阳火神的美丽人生 - 本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、HTML5、Arduino、pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作。
[iOS][兼容性]iOS7 pushViewController,popViewControllerAnimated存在的问题
出现如上链接中提到的问题,懒得再描述了。
其给出的解决办法
dispatch_async(dispatch_get_main_queue(), ^{ [currentViewController PushViewController:viewController animation:animation]; });
实践,这种办法没有效果,倒是利用延时之前解决过 push 同时隐藏 tabbar 时下方闪黑的问题:
__block UIViewController *weakSelf = self; dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)); dispatch_after(delayTime, dispatch_get_main_queue(), ^{ [weakSelf performSelectorOnMainThread:@selector(delayPush:) withObject:viewController waitUntilDone:YES]; }); currentController.extendedLayoutIncludesOpaqueBars = NO; currentController.navigationController.navigationBar.translucent = NO; currentController.edgesForExtendedLayout = UIRectEdgeNone;//UIRectEdgeTop | UIRectEdgeBottom | UIRectEdgeLeft | UIRectEdgeRight;}- (void)delayPush:(UIViewController *)controller { [self pushViewController:controller animated:YES];}@end
只不过,我这是在主线程延时执行。
是否把它的 dispatch_async 换成我的 dispatch_after 并指定个延时时间会有效果。
下面列一下我的解决办法。
我是想把前面的 Controller 都静默 pop 掉,然后再 push 一个,这样最后这个 controller 返回时,是首页。
分析 push 与 pop ,最终都是对 UINavigationController 的 viewcontrollers 数组进行管理并配以相应动画,这样的出栈、入栈操作,可以直接对 viewcontrollers 进行。
UIViewController *mainController = self.navigationController.viewControllers[0]; NSArray *controllers = [NSArray arrayWithObjects:mainController, controller, nil]; [self.navigationController setViewControllers:controllers animated:YES];
好了,问题就这样解决了,把所有的变化集中在 viewcontrollers 的变化中,一次性交给 UINavigationController 进处理。
补充:
实践证明,上面的猜测是不可以的
[self.navigationController popToRootViewControllerAnimated:NO]; dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)); dispatch_after(delayTime, dispatch_get_main_queue(), ^{ [self.navigationController pushViewController:controller animated:YES]; });
还是得用上面重构 viewcontrollers 来调整。
0 0
- iOS 10 中导航控制器出栈入栈连续操作存在的问题
- iOS开发中带导航控制器的屏幕旋转问题
- iOS中导航控制器的使用 UINavigationController
- ios中导航控制器的使用
- iOS 导航控制器、导航条、导航项、控制器的关系
- ios--导航控制器的基本概念
- iOS导航控制器的使用
- iOS导航控制器的注意事项
- iOS中自定义导航控制器NavigationController
- CURD中添加操作存在的问题?
- IOS导航控制器的随堂笔记
- IOS-导航视图控制器的使用
- 导航控制器的使用——IOS
- IOS导航控制器的手势滑动后退
- iOS 9的自定义导航控制器
- iOS 导航控制器相关的设置
- 手动操作导航控制器的子视图控制器的数组
- iOS响应者链介绍,以及通过响应者链实现控制器的跳转(导航控制器的push操作)
- linux内核面试题及答案整理
- datagrid中load,reload,loadData方法的区别
- 块存储
- 图片占用内存计算方法
- ValueError: The indices for endog and exog are not aligned
- iOS 10 中导航控制器出栈入栈连续操作存在的问题
- 连接fatfs与SD卡
- Android学习——自定义布局LinearLayout,参数LayoutParams
- Android Java Socket实现文件上传(二)——服务端
- iOS判断NSDictionary中含有某个key
- ArrayBuffer:类型化数组
- socket
- Tomcat如何实现Comet
- iOS开源项目周报1215