我原先是这么做的,通常也是这么做

- (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中加载,我哪里没注意到望大神告知

最新文章

  1. OpenCV图像金字塔:高斯金字塔、拉普拉斯金字塔与图片尺寸缩放
  2. 【BZOJ】【4011】【HNOI2015】落忆枫音
  3. java程序查不出数据来
  4. IE兼容问题
  5. win7使用USB转串口连接mini2440方法
  6. Fedora 启动 SSH服务
  7. Swing-JTable用法-入门
  8. HDU 3689 Infinite monkey theorem [KMP DP]
  9. IntelliJ Idea常用的快捷键
  10. Android NDK开发method GetStringUTFChars’could not be resolved
  11. prototype 与 proto的关系是什么:
  12. XSS测试代码
  13. .whl文件打开方式 Python
  14. java 类加载机制和反射机制
  15. (1)H5实现音乐播放器【正在播放-歌词篇】
  16. PowerBI开发 第六章:数据网管
  17. Java Web不能不懂的知识
  18. 树(Tree,UVA 548)
  19. css3 字体渐变
  20. 谈谈对final的理解

热门文章

  1. asp.net using library ClosedXML to export excel
  2. 使用CCUserDefault 推断用户是否是第一次登陆系统及UserDefault全路径的获取
  3. 通知中心 NSNotificationCenter
  4. Android -- Messager与Service
  5. noip 2012 开车旅行
  6. vs2012加载EntityFrameWork框架,连接Oracel
  7. asp.net微信开发第八篇----永久素材管理
  8. phpMyAdmin配置及 错误 缺少 mysqli 扩展。请检查 PHP 配置
  9. Nginx配置域名转发实例
  10. 禁止Windows远程桌面拷贝文件