ios学习之 初识UINavigationController
2015-07-21 13:57
375 查看
今天学习了UINavigationController,在这里总结一下使用方法
UINavigationController继承自UIViewController,在其基础上封装了头部导航
下面来看看如何使用UINavigationController,首先在AppDelegate.h中添加属性,如下:
然后将UINavigationController加入到window中,再将需要展示的UIViewController加入到UINavigationController中
NS_CLASS_AVAILABLE_IOS(2_0) @interface UINavigationController : UIViewController
UINavigationController继承自UIViewController,在其基础上封装了头部导航
下面来看看如何使用UINavigationController,首先在AppDelegate.h中添加属性,如下:
#import <UIKit/UIKit.h> #import "ViewController.h" @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (strong,nonatomic) ViewController *vc;//需要显示的ViewController @property (strong,nonatomic) UINavigationController *navController;//声明一个UINavigationController @end
然后将UINavigationController加入到window中,再将需要展示的UIViewController加入到UINavigationController中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]]; //初始化要显示的ViewController self.vc=[[ViewController alloc]init]; //先初始化UINavigationController,再将vc加入UINavigationController,再把UINavigationController加入到window中,以下两种方式都可以实现 //1 self.navController=[[UINavigationController alloc]init]; [self.navController pushViewController:self. vc animated:true]; [self.window addSubview:self.navController.view]; //2 self.window.rootViewController=[[UINavigationController alloc]initWithRootViewController:self.vc]; [self.window makeKeyAndVisible]; return YES; }
相关文章推荐
- while循环中,break,continue,return的区别
- UITableviewCell滑动出现多级的控制按钮 - UITableViewRowAction
- poj 1679 The Unique MST
- poj 1679 The Unique MST
- SolrJ、Request Handler
- 管理系统UI之四:使用全屏沉浸模式(Using Immersive Full-Screen Mode)
- 响应UI可见性的变化
- iOS8新特性之---- UIAlertController解析
- firefox os 2.1版本号UI接口方面有了质的飞跃
- POJ 1019 Number Sequence
- UITableView以及cell属性
- guestmount
- CodeForces 484B Maximum Value
- IOS学习笔记UIButton
- guestfish 修改 image file
- 设置UIView几个角为圆角
- YUI Compressor使用配置方法 JS/CSS压缩工具
- iOS7中计算UILabel中字符串的高度
- iOS-Core-Animation-Advanced-Techniques(六)
- iOS-Core-Animation-Advanced-Techniques(四)