iOS开发UINavigation系列四——导航控制器UINavigationController

  • 时间:
  • 浏览:0

1

- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC ;

- (void)setViewControllers:(NSArray<UIViewController *> *)viewControllers animated:(BOOL)animated;

9

@property (nonatomic, readonly, assign) UITapGestureRecognizer *barHideOnTapGestureRecognizer;

@property(nonatomic) BOOL hidesBottomBarWhenPushed;

13

3

3

7

1

11

7

4

- (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController NS_AVAILABLE_IOS(7_0);

12

2

6

8

2

        在前面的博客中,我么你介绍了UINavigationBar,UINavigationItem和UIToolBar,UINavigationController是将哪些地方地方控件和UIViewController紧密的结合了起来,使用导航,朋友 的应用系统应用应用程序层次会更加分明,对controller的管理也更加方便。前几篇博客地址如下:

10

6

iOS8中增加的哪些地方地土办法律土办法,不得不说着嘴笨 用户体验生进了一大步,从中也可不才能 看出apple对于用户体验度的用心。

2

6

@property(nonatomic,readonly,strong) UINavigationItem *navigationItem;

4

14

@property(nonatomic,readonly) UINavigationBar *navigationBar;

10

UINavigationItem:http://my.oschina.net/u/2340830/blog/527781

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;

@property(nullable, nonatomic,readonly,strong) UIViewController *visibleViewController;

@property(nonatomic,getter=isToolbarHidden) BOOL toolbarHidden NS_AVAILABLE_IOS(3_0);

@property(null_resettable,nonatomic,readonly) UIToolbar *toolbar;

- (UIInterfaceOrientation)navigationControllerPreferredInterfaceOrientationForPresentation:(UINavigationController *)navigationController NS_AVAILABLE_IOS(7_0);

6

4

5

1

- (nullable UIViewController *)popViewControllerAnimated:(BOOL)animated;

上面俩个 多法律土办法的区别在于,topViewController是返回被push出的最后俩个 多controller,因此 肯能之前 又有present进行莫泰跳转,visibleViewController会返回当前显示的controller。类事A-push-B-present-C,则topViewController会返回B,visibleViewController会返回C。

4

@property (nonatomic, readwrite, assign) BOOL hidesBarsOnTap;

8

@property(nullable, nonatomic,readonly,strong) UINavigationController *navigationController;

5

5

3

@property(nullable, nonatomic, readonly) UIGestureRecognizer *interactivePopGestureRecognizer;

7

8

- (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated;

3

@property (nonatomic, readonly, strong) UIPanGestureRecognizer *barHideOnSwipeGestureRecognizer;

3

- (void)setToolbarHidden:(BOOL)hidden animated:(BOOL)animated;

- (void)showViewController:(UIViewController *)vc sender:(nullable id)sender;

10

5

4

2

@property (nonatomic, readwrite, assign) BOOL hidesBarsOnSwipe;

14

1

15

7

- (nullable NSArray<__kindof UIViewController *> *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated; 

        导航控制器还提供了一些代理回调法律土办法,如下:

1

2

4

- (nullable NSArray<__kindof UIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated;

1

12

1

@property (nonatomic, readwrite, assign) BOOL hidesBarsWhenKeyboardAppears;

2

2

- (instancetype)initWithRootViewController:(UIViewController *)rootViewController;

6

4

        导航控制器是俩个 多堆栈特征,因此 其中管理的对象是controller,通过push与pop进行controller的切换,朋友 有两种法律土办法可不才能 创建导航控制器:

@property(nonatomic,copy) NSArray<__kindof UIViewController *> *viewControllers;

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

9

UINavigationBar:http://my.oschina.net/u/2340830/blog/527706

通过以下法律土办法对视图控制器进行管理操作:

@property(nullable, nonatomic,readonly,strong) UIViewController *topViewController; 

UIToolBar:http://my.oschina.net/u/2340830/blog/528168

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated;

3

5

10

11

@property (nonatomic, readwrite, assign) BOOL hidesBarsWhenVerticallyCompact;

9

- (instancetype)initWithNavigationBarClass:(nullable Class)navigationBarClass toolbarClass:(nullable Class)toolbarClass;

        当俩个 多controller被添加到导航中后,系统会为它分配一些属性,如下:

13

3

8

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

- (nullable id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController;

9

11