【UIKit-65-1】#import <UIKit/UINavigationController.h>UINavgationVC基础


@interface UINavigationController : UIViewController


初始化

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

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

    //自定义?
//    UINavigationController *nav = [[UINavigationController alloc]initWithNavigationBarClass:[UINavigationController class] toolbarClass:[UIToolbar class]];
  
    
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    ViewController *view = [ViewController new];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:view];
    
    
    self.window.rootViewController = nav;
    
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    



push pop

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

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

- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated; 

- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated; 

    oneViewController *one = [oneViewController new];
    [self.navigationController pushViewController:one animated:YES];
    
    [self.navigationController popViewControllerAnimated:YES];
    
    ViewController *view = [ViewController new];
    [self.navigationController popToViewController:view animated:YES];
    [self.navigationController popToViewController:view animated:YES];
    
    [self.navigationController popToRootViewControllerAnimated:YES];
    



@property(nonatomic,readonly,retain) UIViewController *topViewController; 顶部vc

@property(nonatomic,readonly,retain) UIViewController *visibleViewController; 可见vc




所有push的vc,也可以直接push过去(跨越多个vc)

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

- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated NS_AVAILABLE_IOS(3_0); 

    oneViewController *one = [oneViewController new];
    twoViewController *two = [twoViewController new];
    
    NSArray *arr = self.navigationController.viewControllers;
    NSLog(@"%@",arr);
    
    [self.navigationController setViewControllers:@[self,one,two]];


NavigationBar push pop 时是否隐藏,以及 bar :具体看 NavigationBar 

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

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

@property(nonatomic,readonly) UINavigationBar *navigationBar;

    oneViewController *one = [oneViewController new];
    
    [self.navigationController setNavigationBarHidden:YES];或者:
    self.navigationController.navigationBarHidden = YES;

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



Toolbar push pop 时是否隐藏,以及 bar :具体看 NavigationBar  同上

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

- (void)setToolbarHidden:(BOOL)hidden animated:(BOOL)animated NS_AVAILABLE_IOS(3_0);

@property(nonatomic,readonly) UIToolbar *toolbar NS_AVAILABLE_IOS(3_0); 

    oneViewController *one = [oneViewController new];

    [self.navigationController setToolbarHidden:YES];
    self.navigationController.toolbarHidden = YES;

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




@property(nonatomic, assign) id<UINavigationControllerDelegate> delegate;   nav 的代理,具体看代理方法



左侧向右滑动,代替pop,(也可以自己设置方法,但是注意需要手势代理)

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

//    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    [self.navigationController.interactivePopGestureRecognizer addTarget:self action:@selector(newPop)];


-(void)newPop{
    NSLog(@"pop");
}



@end


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值