第十章 UINavigationController 翻译
2016-05-09 16:33
603 查看
一,可以用于创建有关联关系的页面
二,UINavigationController
1,UINavigationController维护一个多屏幕的堆栈,每个screen都是一个viewController
2,UINavigationController继承于viewController,它的view属性包含一个UINavigationBar和topViewController的view;
3,可以直接将UINavigationController添加到window中,这样也可以做到UINavigationController的切换
四,使用UINavigationController进行页面导航
1,初始化UINavigationController必须有一个controller
2,可以使用controller的navigationController访问UINavigationController
3,可以使用navigationController的pushViewController:animated:添加一个controller
4,所有加入到navigationController的controller构成一个堆栈关系
五,在controller之间传递数据
1,可以直接在controller之间传递数据
2,一般可以将数据都放在root controller中,并传递到下一级的controller
六,隐藏或显示views
1,使用[self.view endEditing:YES];来释放focus,并隐藏键盘
2,使用self.tableView reloadData来刷新tableView的显示
七,UINavigationBar
1,UIViewController有一个UINavigationItem的属性,navigationController使用它来初始化导航条
2,手动创建action连接
3,连接编辑模式
navItem.leftBarButtonItem = self.editButtonItem;
viewController访问editButtonItem时候,会创建并返回UIBarButtonItem
4,UINavigationItem不是一个view
一,可以用于创建有关联关系的页面
二,UINavigationController
1,UINavigationController维护一个多屏幕的堆栈,每个screen都是一个viewController
2,UINavigationController继承于viewController,它的view属性包含一个UINavigationBar和topViewController的view;
3,可以直接将UINavigationController添加到window中,这样也可以做到UINavigationController的切换
四,使用UINavigationController进行页面导航
1,初始化UINavigationController必须有一个controller
2,可以使用controller的navigationController访问UINavigationController
3,可以使用navigationController的pushViewController:animated:添加一个controller
4,所有加入到navigationController的controller构成一个堆栈关系
五,在controller之间传递数据
1,可以直接在controller之间传递数据
2,一般可以将数据都放在root controller中,并传递到下一级的controller
六,隐藏或显示views
1,使用[self.view endEditing:YES];来释放focus,并隐藏键盘
2,使用self.tableView reloadData来刷新tableView的显示
七,UINavigationBar
1,UIViewController有一个UINavigationItem的属性,navigationController使用它来初始化导航条
2,手动创建action连接
3,连接编辑模式
navItem.leftBarButtonItem = self.editButtonItem;
viewController访问editButtonItem时候,会创建并返回UIBarButtonItem
4,UINavigationItem不是一个view
二,UINavigationController
1,UINavigationController维护一个多屏幕的堆栈,每个screen都是一个viewController
2,UINavigationController继承于viewController,它的view属性包含一个UINavigationBar和topViewController的view;
3,可以直接将UINavigationController添加到window中,这样也可以做到UINavigationController的切换
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]]; // Override point for customization after application launch BNRItemsViewController *itemsViewController = [[BNRItemsViewController alloc] init]; // Create an instance of a UINavigationController // its stack contains only itemsViewController UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:itemsViewController]; // Place navigation controller's view in the window hierarchy self.window.rootViewController = navController; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; }
四,使用UINavigationController进行页面导航
1,初始化UINavigationController必须有一个controller
2,可以使用controller的navigationController访问UINavigationController
3,可以使用navigationController的pushViewController:animated:添加一个controller
@implementation BNRItemsViewController - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { BNRDetailViewController *detailViewController = [[BNRDetailViewController alloc] init]; // Push it onto the top of the navigation controller's stack [self.navigationController pushViewController:detailViewController animated:YES]; }
4,所有加入到navigationController的controller构成一个堆栈关系
五,在controller之间传递数据
1,可以直接在controller之间传递数据
2,一般可以将数据都放在root controller中,并传递到下一级的controller
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { BNRDetailViewController *detailViewController = [[BNRDetailViewController alloc] init]; NSArray *items = [[BNRItemStore sharedStore] allItems]; BNRItem *selectedItem = items[indexPath.row]; // Give detail view controller a pointer to the item object in row detailViewController.item = selectedItem; [self.navigationController pushViewController:detailViewController animated:YES]; }
六,隐藏或显示views
1,使用[self.view endEditing:YES];来释放focus,并隐藏键盘
2,使用self.tableView reloadData来刷新tableView的显示
七,UINavigationBar
1,UIViewController有一个UINavigationItem的属性,navigationController使用它来初始化导航条
2,手动创建action连接
- (instancetype)init { self = [super initWithStyle:UITableViewStylePlain]; if (self) { UINavigationItem *navItem = self.navigationItem; navItem.title = @"Homepwner"; // Create a new bar button item that will send // addNewItem: to BNRItemsViewController UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addNewItem:)]; // Set this bar button item as the right item in the navigationItem navItem.rightBarButtonItem = bbi; } return self; }
3,连接编辑模式
navItem.leftBarButtonItem = self.editButtonItem;
viewController访问editButtonItem时候,会创建并返回UIBarButtonItem
4,UINavigationItem不是一个view
一,可以用于创建有关联关系的页面
二,UINavigationController
1,UINavigationController维护一个多屏幕的堆栈,每个screen都是一个viewController
2,UINavigationController继承于viewController,它的view属性包含一个UINavigationBar和topViewController的view;
3,可以直接将UINavigationController添加到window中,这样也可以做到UINavigationController的切换
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]]; // Override point for customization after application launch BNRItemsViewController *itemsViewController = [[BNRItemsViewController alloc] init]; // Create an instance of a UINavigationController // its stack contains only itemsViewController UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:itemsViewController]; // Place navigation controller's view in the window hierarchy self.window.rootViewController = navController; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; }
四,使用UINavigationController进行页面导航
1,初始化UINavigationController必须有一个controller
2,可以使用controller的navigationController访问UINavigationController
3,可以使用navigationController的pushViewController:animated:添加一个controller
@implementation BNRItemsViewController - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { BNRDetailViewController *detailViewController = [[BNRDetailViewController alloc] init]; // Push it onto the top of the navigation controller's stack [self.navigationController pushViewController:detailViewController animated:YES]; }
4,所有加入到navigationController的controller构成一个堆栈关系
五,在controller之间传递数据
1,可以直接在controller之间传递数据
2,一般可以将数据都放在root controller中,并传递到下一级的controller
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { BNRDetailViewController *detailViewController = [[BNRDetailViewController alloc] init]; NSArray *items = [[BNRItemStore sharedStore] allItems]; BNRItem *selectedItem = items[indexPath.row]; // Give detail view controller a pointer to the item object in row detailViewController.item = selectedItem; [self.navigationController pushViewController:detailViewController animated:YES]; }
六,隐藏或显示views
1,使用[self.view endEditing:YES];来释放focus,并隐藏键盘
2,使用self.tableView reloadData来刷新tableView的显示
七,UINavigationBar
1,UIViewController有一个UINavigationItem的属性,navigationController使用它来初始化导航条
2,手动创建action连接
- (instancetype)init { self = [super initWithStyle:UITableViewStylePlain]; if (self) { UINavigationItem *navItem = self.navigationItem; navItem.title = @"Homepwner"; // Create a new bar button item that will send // addNewItem: to BNRItemsViewController UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addNewItem:)]; // Set this bar button item as the right item in the navigationItem navItem.rightBarButtonItem = bbi; } return self; }
3,连接编辑模式
navItem.leftBarButtonItem = self.editButtonItem;
viewController访问editButtonItem时候,会创建并返回UIBarButtonItem
4,UINavigationItem不是一个view
相关文章推荐
- 数据库重构工具 LiquiBase(5 Liquibase被锁)
- Liquibase被锁
- 集合框架--Map集合values
- ArrayList的<STRING>到CharSequence的[]
- EqualsBuilder和HashCodeBuilder 作用
- iOS--UITableViewCell去除重影的方法
- Moqui学习之 Step by Step OrderProcureToPayBasicFlow
- 利用quic协议访问google
- UIView与CALayer
- 简单实现跑马灯效果
- 自己写的一个php基于phpQuery的通用采集类
- UIDatePicker转为汉字,并且显示年月日
- iOS自定义弹窗(UIView)
- ISO中根据URL下载图片,请求图片
- ui-router使用方法
- hdoj-5301-Buildings
- 347. Top K Frequent Elements【M】【VIP】【字典排序】
- 347. Top K Frequent Elements
- [BS-17] iOS开发-Alpha,Hidden和Opaque区别
- Installation error: INSTALL_FAILED_UID_CHANGED解决方案