码迷,mamicode.com
首页 > 其他好文 > 详细

UINavigationController详解

时间:2015-08-31 16:47:17      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

 

通过这个接口可以初始化自定义的工具栏和导航栏

- (instancetype)initWithNavigationBarClass:(Class)navigationBarClass toolbarClass:(Class)toolbarClass NS_AVAILABLE_IOS(5_0)

 

使用水平滑动过渡。如果视图控制器已在堆栈中在调用就没有效果

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated; 

 

将栈顶的控制器弹出并返回这个弹出的控制器

- (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.

 

返回栈顶控制器

@property(nonatomic,readonly,retain) UIViewController *topViewController; // The top view controller on the stack.

返回模态视图控制器如果有的话,否则就是栈顶的控制器

@property(nonatomic,readonly,retain) UIViewController *visibleViewController; // Return modal view controller if it exists. Otherwise the top view controller.

 

当前导航控制器的视图控制器栈

@property(nonatomic,copy) NSArray *viewControllers; // The current view controller stack.

设置导航控制器的栈集合

- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated NS_AVAILABLE_IOS(3_0); // If animated is YES, then simulate a push or pop depending on whether the new top view controller was previously in the stack.

 

显示/隐藏导航栏

@property(nonatomic,getter=isNavigationBarHidden) BOOL navigationBarHidden;

 

滑动返回手势

@property(nonatomic, readonly) UIGestureRecognizer *interactivePopGestureRecognizer NS_AVAILABLE_IOS(7_0);

据说在自定义了leftBarbuttonItem后左滑返回手势失效了怎么办?

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
                                         initWithImage:img
                                         style:UIBarButtonItemStylePlain
                                         target:self
                                         action:@selector(onBack:)];
self.navigationController.interactivePopGestureRecognizer.delegate = (id<uigesturerecognizerdelegate>)self;
 
同pushViewController:animated:相同

- (void)showViewController:(UIViewController *)vc sender:(id)sender NS_AVAILABLE_IOS(8_0); // Interpreted as pushViewController:animated:

 

 

 

UINavigationController详解

标签:

原文地址:http://www.cnblogs.com/HypeCheng/p/4773062.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!