iOS开发手记 - iOS9.3 UINavigationController添加后不显示storyboard中viewcontroller里的控件的解决方法
2024-08-27 00:33:39
我原先是这么做的,通常也是这么做
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
ViewController *firstVC = [[ViewController alloc] init];
UINavigationController *naviController = [[UINavigationController alloc] initWithRootViewController:firstVC];
self.window.rootViewController = naviController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
然而运行后,UINavigationController的确作为windows的根视图显示了,但是firstVC里的控件却没有显示,一片空白
事实证明不能这样直接alloc firstVC,而是要从storyboard中加载,我改成如下就行了:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main_" bundle:nil];
ViewController *firstVC = [storyBoard instantiateViewControllerWithIdentifier:@"MainView"];
UINavigationController *naviController = [[UINavigationController alloc] initWithRootViewController:firstVC];
self.window.rootViewController = naviController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
我查看过很多代码例子都是像前者一样直接alloc加载就可以,但是我这里却不行,一定要这样从storyboard中加载,我哪里没注意到望大神告知
最新文章
- OpenCV图像金字塔:高斯金字塔、拉普拉斯金字塔与图片尺寸缩放
- 【BZOJ】【4011】【HNOI2015】落忆枫音
- java程序查不出数据来
- IE兼容问题
- win7使用USB转串口连接mini2440方法
- Fedora 启动 SSH服务
- Swing-JTable用法-入门
- HDU 3689 Infinite monkey theorem [KMP DP]
- IntelliJ Idea常用的快捷键
- Android NDK开发method GetStringUTFChars’could not be resolved
- prototype 与 proto的关系是什么:
- XSS测试代码
- .whl文件打开方式 Python
- java 类加载机制和反射机制
- (1)H5实现音乐播放器【正在播放-歌词篇】
- PowerBI开发 第六章:数据网管
- Java Web不能不懂的知识
- 树(Tree,UVA 548)
- css3 字体渐变
- 谈谈对final的理解
热门文章
- asp.net using library ClosedXML to export excel
- 使用CCUserDefault 推断用户是否是第一次登陆系统及UserDefault全路径的获取
- 通知中心 NSNotificationCenter
- Android -- Messager与Service
- noip 2012 开车旅行
- vs2012加载EntityFrameWork框架,连接Oracel
- asp.net微信开发第八篇----永久素材管理
- phpMyAdmin配置及 错误 缺少 mysqli 扩展。请检查 PHP 配置
- Nginx配置域名转发实例
- 禁止Windows远程桌面拷贝文件