Single View Application 中使用 UINavigationController
来源:互联网 发布:vmware 网络桥接linux 编辑:程序博客网 时间:2024/05/12 00:03
首先通过File - New - New Project 创建一个Single View Application
然后将didFinishLaunchingWithOptions的方法发为下面的. 主要是定义一个UINavigationController, 然后定义其的rootViewController为MainViewController
然后, 返回MainViewController, 定义一个button, 定义buttonpressed事件.
此时运行项目, 点击按钮, 就会切换到SubNavController中了~ 上面会显示出"返回"的按钮.
项目创建之后, 再通添加文件 - Coca Touch - UIViewController 创建MainViewController, 其中xib项需要选中.
同样的方法创建一个SubViewController.
切换回AppDelegate.m 添加
#import "MainViewController.h"
然后将didFinishLaunchingWithOptions的方法发为下面的. 主要是定义一个UINavigationController, 然后定义其的rootViewController为MainViewController
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. //self.viewController = [[NavViewController alloc] initWithNibName:@"NavViewController" bundle:nil]; //self.window.rootViewController = self.viewController; self.viewController= [[NavViewController alloc] initWithNibName:@"NavViewController" bundle:nil]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.viewController]; [self.window addSubview:nav.view]; [self.window makeKeyAndVisible]; return YES;}
然后, 返回MainViewController, 定义一个button, 定义buttonpressed事件.
返回nib, 拖一个按钮到window上面, 通过拖拽建立起关联.
-(IBAction)buttonPressed{ self.sub = [[SubNavController alloc] initWithNibName:@"SubNavController" bundle:nil]; [self.navigationController pushViewController:self.sub animated:YES]; [self.sub release];}
此时运行项目, 点击按钮, 就会切换到SubNavController中了~ 上面会显示出"返回"的按钮.
此外, Navigation拥有下面的属性, 都可以自己定义.
-title
-titleview
-backBarButtonItem
-rightBarButtonItem
-leftBarButtonItem
- Single View Application 中使用 UINavigationController
- 在modal view中使用UINavigationController
- Single View Application应用剖析
- 从 Empty Application 到 Single View Application
- single view application中删除默认的scene,创建导航视图不能显示
- Single View Application改成空模板的步骤(xcode6.0.1)
- 在presentModalViewController中使用UINavigationController
- 在presentModalViewController中使用UINavigationController
- swift中UINavigationController的使用
- iOS中导航控制器的使用 UINavigationController
- UINavigationController使用
- UINavigationController使用
- Xcode and iOS Simulator issue report: got 'Thread 1: Signal SIGABRT' for single view application
- WPF Single Instance Application
- Single Page Application是什么
- Xcode上新建工程,将Single View Application模板的工程修改为Empty Application模板的工程
- 类中使用application
- Android 中使用 Application
- error C2504: 'CTreeView ' : base class undefined
- string::npos,图标导入及调试技巧
- 我的js学习笔记之创建对象
- CPropertyPage 间的数据传递
- oracle Temp 管理
- Single View Application 中使用 UINavigationController
- Android数据处理---SQLite
- ADO.net连接项目中mdf数据库代码
- Android2.3触摸屏功能详解
- unix中文件夹或文件名带空格的处理
- Android系统文件夹结构的说明
- Spring Mail中文乱码问题
- HTTP中Get与Post的区别
- PLSQL基本结构