iOS开发注销操作后更改rootViewController的问题
2015-09-09 17:06
579 查看
刚才遇到一个问题,现在在这就当纪录一下,大家有遇到的能快速找到原因,分享一下啊。
在APP中,需要用户登录后才能使用,所以我通过更改APP的[UIApplicationsharedApplication].keyWindow.rootViewController来控制界面的跳转。
在使用过程中出现如下问题:
1.登录成功后点击注销按钮,弹出注销提示框UIAlertView;
2.注销成功后重新登录;
3.再次点击注销不再弹出UIAlertView。
提示如下警告:
点击注销按钮执行更改rootvie操作:
attempt to dismiss modal view controller whose view does not currently appear
再次点击注销的时候提示:
Attempt to present <_UIModalItemsPresentingViewController: 0x7f9d1b5b2fd0> on <_UIModalItemAppViewController: 0x7f9d1d335520> whose view isnotin
the window hierarchy!
我的代码是:
LoginViewController *loginVC = [[LoginViewControlleralloc]init];
CNavigationController *nav = [[CNavigationControlleralloc]initWithRootViewController:loginVC];
[UIApplicationsharedApplication].keyWindow.rootViewController
= nav;
造成这个的原因主要是:因为我执行上述代码是在:-(void)alertView:(UIAlertView
*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex的这个方法执行的,所以在我执行切换根视图控制器的时候UIAlertView是还没有消失的,所以会出现上述错误,UIAlertView的消失是需要一定的时间的,
解决方案:
要解决这个问题,就是在UIAlertView的另一个代理方法-(void)alertView:(UIAlertView
*)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex中执行切换根控制器的操作,即上述我的代码,也就是说在UIAlertView彻底消失后再执行切换根控制器,解决!
在APP中,需要用户登录后才能使用,所以我通过更改APP的[UIApplicationsharedApplication].keyWindow.rootViewController来控制界面的跳转。
在使用过程中出现如下问题:
1.登录成功后点击注销按钮,弹出注销提示框UIAlertView;
2.注销成功后重新登录;
3.再次点击注销不再弹出UIAlertView。
提示如下警告:
点击注销按钮执行更改rootvie操作:
attempt to dismiss modal view controller whose view does not currently appear
再次点击注销的时候提示:
Attempt to present <_UIModalItemsPresentingViewController: 0x7f9d1b5b2fd0> on <_UIModalItemAppViewController: 0x7f9d1d335520> whose view isnotin
the window hierarchy!
我的代码是:
LoginViewController *loginVC = [[LoginViewControlleralloc]init];
CNavigationController *nav = [[CNavigationControlleralloc]initWithRootViewController:loginVC];
[UIApplicationsharedApplication].keyWindow.rootViewController
= nav;
造成这个的原因主要是:因为我执行上述代码是在:-(void)alertView:(UIAlertView
*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex的这个方法执行的,所以在我执行切换根视图控制器的时候UIAlertView是还没有消失的,所以会出现上述错误,UIAlertView的消失是需要一定的时间的,
解决方案:
要解决这个问题,就是在UIAlertView的另一个代理方法-(void)alertView:(UIAlertView
*)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex中执行切换根控制器的操作,即上述我的代码,也就是说在UIAlertView彻底消失后再执行切换根控制器,解决!
相关文章推荐
- iOS开发之路--微博“更多”页面
- iOS开发之路--微博骨架搭建
- IOS开发代码分享之获取启动画面图片的string
- IOS开发之路--C语言数组和字符串
- IOS开发代码分享之用nstimer实现倒计时功能
- IOS开发代码分享之设置UISearchBar的背景颜色
- ios开发之环境搭建-01
- 在开发iOS程序时对日期处理的总结
- iOS开发——keychain的使用
- iOS Graphics Technologies iOS 图形技术
- iOS开发异常错误总结
- 学习Objective-C:入门手册
- iOS开发 简单实现视频音频的边下边播
- iOS开发 — Quartz 2D知识点应用 (制作了一个Demo,源代码)
- ios开发对配置文件plist的操作
- iphone5和4的屏幕兼容问题
- 9秒的课程只为培养靠谱的IOS和HTML5开发人才而定制
- iOS开发学习笔记 1-0 开篇
- iOS开发学习笔记 2-1 C语言部分 初识C语言
- iOS开发学习笔记 2-2 C语言部分 类型、运算符与表达式