UINavigationController(导航控制器)及跳转页面的方法

[self.navigationController pushViewController:_registVC animated:YES];

一.UINavigationController(导航控制器)

UINavigationController可以控制多个UIViewController

1.初始化一个UINavigationController

<span style="font-size:14px;">self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    [self.window makeKeyAndVisible];
    
    LoginViewController *loginVC = [[LoginViewController alloc]init];
    
    UINavigationController *navigationVC = [[UINavigationController alloc]initWithRootViewController:loginVC];
    
    self.window.rootViewController = navigationVC;</span>

2.添加UINavigation

//UIBarButtonItem继承于UIBarItem
    
    //1.初始化一个UIBarButtonItem
    UIBarButtonItem *btnItem = [[UIBarButtonItem alloc]initWithTitle:@"注册" style:UIBarButtonItemStyleDone target:self action:@selector(btnItemAction:)];
    
    /*
    //2.title:修改UIBarButtonItem的名称
    btnItem.title = @"adklfj";
    
    //3.enabled:标识UIBarButtonItem是否为可编辑,其默认值为YES.
    btnItem.enabled = NO;
    
    //4.image:给UIBarButtonItem设置一张图片
    btnItem.image = [[UIImage imageNamed:@"zx"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    */
    
    
    //5.修改UINavigationController的title.
    self.navigationItem.title = @"登陆";
    
    //6.navigationBarHidden:隐藏navigationController的导航栏,默认值是NO
    self.navigationController.navigationBarHidden = NO;
    
    //7.//navigationBar:设置navigationBar.<span style="color:#FF0000;">translucent</span>(透明度)的值为NO,其默认值是YES;设置navigationBar的值为NO后,视图的(0,0)点就是在navigationBar的左下角.
    self.navigationController.navigationBar.translucent = NO;
    

二.跳转页面的方法

1.从前往后跳转页面

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated; 
// Uses a horizontal slide transition. Has no effect if the view controller is already in the stack.
例如:
[self.navigationController pushViewController:_registVC animated:YES];

2.从后往前跳转页面


//这个方法是返回前一个界面
- (UIViewController *)popViewControllerAnimated:(BOOL)animated; 
// Returns the popped controller.

//这个方法是返回到在同一条链路上的任意一个界面
- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated; 
// Pops view controllers until the one specified is on top. Returns the popped controllers.

//这个方法是返回到根视图
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated; 
// Pops until there's only a single view controller left on the stack. Returns the popped controllers.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值