在presentModalViewController中使用UINavigationController
来源:互联网 发布:蒙顶甘露 知乎 编辑:程序博客网 时间:2024/05/23 15:40
原文:http://blog.csdn.net/mideveloper/article/details/7798872
手上的项目中登陆界面是写在presentModalViewController中的,但是无法使用UINavigationController,后来费了一些时间来弄,可能因为当时思维比较混乱,没有搞定。
今天查到了一篇文章,http://www.giser.net/?p=857 惯例 原文录入,避免个人博客died
在iOS开发中遇到下面的问题,在presentModalViewController出来ViewController的TableView中无法使用navigationController的pushViewController方法弹出新的页面。
后来发现原因ViewController的navigationController的属性为nil。
解决办法为,在presentModalViewController的时候自己创建一个navigationController,这样ViewController的navigationController属性不为nil,即可使用pushViewController。
代码如下:
- POIListViewController * poiListVC = [[POIListViewController alloc] initWithNibName:@"POIListViewController" bundle:nil];
- poiListVC.poisArray = self.searchResult;
- poiListVC.delegate = self;
- UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:poiListVC];
- [self presentModalViewController:navController animated:YES];
- [navController release];
- [poiListVC release];
最后贴上自己的代码
- -(IBAction)logout:(id)sender{
- [ActiveUser sharedActiveUser].logined=NO;
- self.logoutButton.enabled=[ActiveUser sharedActiveUser].logined;
- UILoginViewController* loginViewController=[[UILoginViewController alloc] initFromNib];
- UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:loginViewController];
- navController.navigationBarHidden=YES;
- [[Global sharedGlobal].mainViewController presentModalViewController:navController
- animated:NO];
- [loginViewController release];
- [navController release];
- }
0 0
- 在presentModalViewController中使用UINavigationController
- 在presentModalViewController中使用UINavigationController
- presentModalViewController and UINavigationController
- 在modal view中使用UINavigationController
- 在UINavigationController中使用UITabBarController,处理Two-stage Rotation错误
- 在imagePickerController:didFinishPickingMediaWithInfo:方法中presentModalViewController失效怎么办?
- swift中UINavigationController的使用
- ios中使用PresentModalViewController和dismissModalViewControllerAnimated的总结
- 使用 presentModalViewController 异常
- 正确使用PresentModalViewController
- 正确使用PresentModalViewController
- presentModalViewController的使用
- IOS: 正确使用PresentModalViewController
- IOS: 正确使用PresentModalViewController
- 正确使用PresentModalViewController
- 正确使用PresentModalViewController
- 正确使用PresentModalViewController
- 正确使用PresentModalViewController
- 这周dp(POJ-2229)
- 08-2. 求矩阵的局部极大值(15)
- UVA 11769 All Souls Night 三维凸包求表面积
- Servlet第五课:Cookie的使用
- USACO 回文素数
- 在presentModalViewController中使用UINavigationController
- UVA 12086 - Potentiometers(树状数组)
- 每日 swift 学习 (控制语句)
- mini2440上一步步实现将ADS工程移植到keil MDK(附移植好的完整代码)
- 暑假第二十天,7月26号
- UVA 11770 Lighting Away 强连通缩点+拓扑排序
- Hibernate中离线查询DetachedCriteria案例
- Servlet基础
- hibernate-Query的list方法与iterator方法的区别