UINavigationControllerHideShowBarDuration : push pop 时间
初始化
// UINavigationController *nav = [[UINavigationController alloc]initWithNavigationBarClass:[UINavigationController class] toolbarClass:[UIToolbar class]];
ViewController *view = [ViewController new];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:view];
[UIApplication sharedApplication].keyWindow.rootViewController = guidePageViewController;
转场
oneViewController *one = [oneViewController new];
[self.navigationController pushViewController:one animated:YES];// push 下一个
[self.navigationController popViewControllerAnimated:YES];// pop 上一个 VC
ViewController *view = [ViewController new];
[self.navigationController popToViewController:view animated:YES];// pop 到某个VC
[self.navigationController popToRootViewControllerAnimated:YES];// pop root
oneViewController *one = [oneViewController new];
twoViewController *two = [twoViewController new];
[self.navigationController setViewControllers:@[self,one,two]];// 一次设置多个子VCs
[self.navigationController setViewControllers:@[self,one,two] animated:YES];// 同上
获取
self.navigationController.topViewController;// 顶部
self.navigationController.visibleViewController;// 可见
NSArray *arr = self.navigationController.viewControllers;// 所有
self.navigationController.navigationBar;
self.navigationController.toolbar;
```
## 系统左侧滑
// 左侧向右滑动,代替pop,(也可以自己设置方法,但是注意需要手势代理)
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
self.navigationController.interactivePopGestureRecognizer.delegate = self;
[self.navigationController.interactivePopGestureRecognizer addTarget:self action:@selector(newPop)];
-(void)newPop{
NSLog(@"pop");
}
## 隐藏
// push 隐藏 Nav
oneViewController *one = [oneViewController new];
[self.navigationController setNavigationBarHidden:YES];或者:
self.navigationController.navigationBarHidden = YES;
[self.navigationController pushViewController:one animated:YES];
// 下面toolBar 类似
oneViewController *one = [oneViewController new];
[self.navigationController setToolbarHidden:YES];
self.navigationController.toolbarHidden = YES;
[self.navigationController pushViewController:one animated:YES];
## 代理
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
-
(NSUInteger)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController NS_AVAILABLE_IOS(7_0);
-
(UIInterfaceOrientation)navigationControllerPreferredInterfaceOrientationForPresentation:(UINavigationController *)navigationController NS_AVAILABLE_IOS(7_0);
-
(id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController NS_AVAILABLE_IOS(7_0); -
(id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC NS_AVAILABLE_IOS(7_0);
## 其他
- (void)showViewController:(UIViewController *)vc sender:(id)sender NS_AVAILABLE_IOS(8_0); // Interpreted as pushViewController:animated:
/// When the keyboard appears, the navigation controller's navigationBar toolbar will be hidden. The bars will remain hidden when the keyboard dismisses, but a tap in the content area will show them.
@property (nonatomic, readwrite, assign) BOOL hidesBarsWhenKeyboardAppears NS_AVAILABLE_IOS(8_0);
/// When the user swipes, the navigation controller's navigationBar & toolbar will be hidden (on a swipe up) or shown (on a swipe down). The toolbar only participates if it has items.
@property (nonatomic, readwrite, assign) BOOL hidesBarsOnSwipe NS_AVAILABLE_IOS(8_0);
/// The gesture recognizer that triggers if the bars will hide or show due to a swipe. Do not change the delegate or attempt to replace this gesture by overriding this method.
@property (nonatomic, readonly, retain) UIPanGestureRecognizer *barHideOnSwipeGestureRecognizer NS_AVAILABLE_IOS(8_0);
/// When the UINavigationController's vertical size class is compact, hide the UINavigationBar and UIToolbar. Unhandled taps in the regions that would normally be occupied by these bars will reveal the bars.
@property (nonatomic, readwrite, assign) BOOL hidesBarsWhenVerticallyCompact NS_AVAILABLE_IOS(8_0);
/// When the user taps, the navigation controller's navigationBar & toolbar will be hidden or shown, depending on the hidden state of the navigationBar. The toolbar will only be shown if it has items to display.
@property (nonatomic, readwrite, assign) BOOL hidesBarsOnTap NS_AVAILABLE_IOS(8_0);
/// The gesture recognizer used to recognize if the bars will hide or show due to a tap in content. Do not change the delegate or attempt to replace this gesture by overriding this method.
@property (nonatomic, readonly, assign) UITapGestureRecognizer *barHideOnTapGestureRecognizer NS_AVAILABLE_IOS(8_0);
1