Xcode5使用Main.storyboard作为navigation根目录
来源:互联网 发布:2016双十一淘宝退货率 编辑:程序博客网 时间:2024/06/06 00:04
因为习惯了使用代码写界面,偶尔一次使用控件,记录一下。
最新的Xcode5 使用Main.storyboard作为默认。
首先新建一个项目,选择Single View Application
然后,一路next。工程项目建立完成
打开storyboard
选择一个Navigation Controller拖到图中区域
可以看到,如图。
然后,删除Root View Controller
右击Navigation Controller ,把root 链接到 view Controller上,把上图的箭头放到Navigation左边
现在分析一下,如果,建立完工程后,你直接在代码中,
- (IBAction)action:(id)sender { NSLog(@"self.navigationController is %@",self.navigationController); FirstViewController *first = [[FirstViewController alloc] init]; [self.navigationController pushViewController:first animated:YES];}
你会发现,self.navigaitonController is null,因为没有初始化。之前,我们在代码中的初始化为,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; MainViewController *mainViewController = [[MainViewController alloc] init]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:mainViewController]; self.window.rootViewController = nav; [self.window makeKeyAndVisible]; return YES;}
所以,我们需要,添加一个navigation Controller,设置rootViewController所以出现了上边的操作。
但是,如果你没有把箭头拖到navigation Controller,那还会打印 self.navigaitonController is null,因为此时程序首先加载的还是Main.storyboard。
转载是请保留:来自http://blog.csdn.net/ralbatr
0 0
- Xcode5使用Main.storyboard作为navigation根目录
- Xcode5使用Main.storyboard作为navigation根目录
- 不使用Main.storyboard
- Swift 不使用 main storyBoard
- (xcode5.0 DEV target:iOS5.0) Could not find a storyboard named 'Main' in bundle
- Main.storyboard
- X code及Main.storyboard 基本使用
- iOS StoryBoard中使用navigation bar的问题
- 使用storyboard创建带有navigation的界面的简单方法
- storyboard 添加Navigation Controller
- storyboard Navigation 中间视图
- XCode5取消ARC和StoryBoard
- XCode5取消ARC和StoryBoard
- ios开发----使用代码创建UI界面-----使用Main.storyboard
- iOS storyboard创建Navigation Controller
- 如何删除Main.storyboard而使用xib文件构建界面
- Swift使用Main.storyboard的segue值来回传数据
- Main.storyboard常见警告
- const
-
- Android延时执行的几种方法
- 关于JAVA中的hashcode和equals
- ASM实例参数
- Xcode5使用Main.storyboard作为navigation根目录
- 用css解决table文字溢出控制td显示字数
- Android TextView 个别文字字体颜色格式
- [STL]标准容器
- Broadcom网卡设置影响HyperV虚拟机网络性能
- 传智播客数据绑定和数据库开发基础(第四季)
- Codeforces dp第一弹
- 数据结构之查找一静态查找
- ndk 编译 c++ 兼容性问题汇总整理