UINavigationController
来源:互联网 发布:薛之谦淘宝男装 编辑:程序博客网 时间:2024/05/10 22:15
UINavigationController
When your application presents multiple screens of information, UINavigationController maintains a stack of those screens. The stack is an NSArray of view controllers, and each screen is the view of a UIViewController. When a UIViewController is on top of the stack, its view is visible.
When you initialize an instance of UINavigationController, you give it one UIViewController. This UIViewController is called the root view controller. The root view controller is always on the bottom of the stack.
The UIViewController that is currently on top of the stack is accessed by sending the message topViewController to the UINavigationControllerinstance. You can also get the entire stack as an NSArray by sending the navigation controller the message viewControllers.
The UINavigationController is also a subclass of UIViewController, so it has a view of its own. Its view always has at least two subviews: aUINavigationBar and the view of its topViewController.
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ ItemsViewController *itemsViewController = [[ItemsViewController alloc] init]; // Create an instance of a UINavigationController // its stack contains only itemsViewController UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:itemsViewController]; // You can now release the itemsViewController here, // UINavigationController will retain it [itemsViewController release]; // Place navigation controller's view in the window hierarchy [[self window] setRootViewController:navController]; [navController release]; [[self window] makeKeyAndVisible]; return YES;}
UINavigationBar
The UINavigationBar isn't very interesting right now. At a minimum, a UINavigationBar should display a descriptive title for the UIViewController that is currently on top of the UINavigationController's stack.
Every UIViewContoller has a navigationItem property of type UINavigationItem. However, unlike UINavigationBar, UINavigationItem is not a subclass of UIView, so it cannot appera on the screen. Instead, the navigation item supplies the navigation bar with the contentit needs to draw. When a UIViewController comes to the top of a UINavigationController’s stack, the UINavigationBar uses the UIViewController’s navigationItem to configure itself.
A navigation item can hold more than just a title string. There are three customizable areas for each UINavigationItem: a leftBarButtonItem, a rightBarButtonItem and a titleView. The left and right bar button items are pointers to instances of UIBarButtonItem,which contains the information for a button that can only be displayed on a UINavigationBar or a UIToolbar.
Like UINavigationItem, UIBarButtonItem is not a subclass of UIView but supplies the content that a UINavigationBar needs to draw. Consider the UINavigationItem and its UIBarButtonItems to be containers for strings, images, and other content. A UINavigationBar knows how to look in those containers and draw the content it finds.
navigation with UINavigationController
- (void)tableView:(UITableView *)aTableViewdidSelectRowAtIndexPath:(NSIndexPath *)indexPath{ ItemDetailViewController *detailViewController = [[[ItemDetailViewController alloc] init] autorelease]; NSArray *possessions = [[PossessionStore defaultStore] allPossessions]; // Give detail view controller a pointer to the possession object in row [detailViewController setPossession: [possessions objectAtIndex:[indexPath row]]]; [[self navigationController] pushViewController:detailViewController animated:YES];}
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- 一月计划总结;
- linux下查看系统信息
- 手游上线流程
- ubuntu13.04安装openoffice
- zabbix 安装及简单排错
- UINavigationController
- 【Dom】通过递归获取节点的层次关系
- 竞赛-身材是否标准题
- CMUSphinx Learn - Generating a dictionary
- 查询sql字符串中包含某字符的个数
- 视频专辑:韩顺平PHP视频教程 全面掌握smarty模板技术
- 解决windows下,rake preview后出现“TCPServer Error: Address already in use” 错误
- UINavigationController使用详解
- 使用setsockopt()接口,设置TCP的接收与发送超时,Invalid argument错误问题