iOS--UINavigationController学习笔记

1.简介
        UINavigationController:是iOS常见的一种容器型Controller。官方文档上给出的注释如下
 UINavigationController manages a stack of view controllers and a navigation bar. It performs horizontal view transitions for pushed and popped views while keeping the navigation bar in sync. Most clients will not need to subclass UINavigationController. If a navigation controller is nested in a tabbar controller, it uses the title and toolbar attributes of the bottom view controller on the stack. UINavigationController is rotatable if its top view controller is rotatable. Navigation between controllers with non-uniform rotatability is currently not supported.
意思是说,UINavigationController管理着一个viewController的栈和一个navigation bar(navigation bar后面会说)。管理着出于同一层次的viewController的view,包括压栈和出栈(viewController显示滑进和隐藏滑出界)的转场动画,同时还同步管理着顶部navigation bar的状态。大部分的app都不需要实现一个它的子类(对于一般的功能,都具有支持)。如果一个UINavigationController的实例嵌套在一个UITabbarController的实例中,它将使用栈底的viewController的标题和toolbar的属性。UINavigationController的可旋转是和栈顶的viewController保持一致的。现在还不支持同一层次的viewController旋转类型不一致的压栈出栈。

2.常见属性和方法
- ( instancetype )initWithRootViewController:(UIViewController *)rootViewController; 
以一个viewController为栈底,实例化一个navigation viewcontroller

- ( void )pushViewController:(UIViewController *)viewController animated:( BOOL )animated; 
展示一个viewcontroller,压栈操作(可以有动画效果)。

- ( nullable UIViewController *)popViewControllerAnimated:( BOOL )animated; 
结束并隐藏一个viewcontroller(dealloc),出栈操作(可以有动画效果),返回出栈的viewcontroller

- ( nullable NSArray< __kindof UIViewController *> *)popToViewController:(UIViewController *)viewController animated:( BOOL )animated; 
结束并隐藏 在栈中位于一个特殊的viewcontroller之前所有的viewcontroller,并返回

- ( nullable NSArray< __kindof UIViewController *> *)popToRootViewControllerAnimated:( BOOL )animated;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值