• UISB 导航控制器切换


    scenedelegate.m

    #import "SceneDelegate.h"
    #import "VCRoot.h"
    @interface SceneDelegate ()
    
    @end
    
    @implementation SceneDelegate
    
    
    - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
        self.window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];
        self.window.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
        self.window.rootViewController=[[UINavigationController alloc]initWithRootViewController:[[VCRoot alloc]init]];
        
        [self.window makeKeyAndVisible];
        
        
        
    }

    VCRoot.m

    #import "VCRoot.h"
    #import "VCSecond.h"
    @interface VCRoot ()
    
    @end
    
    @implementation VCRoot
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        //设置导航栏透明度
        self.navigationController.navigationBar.translucent=NO;
        
        self.navigationController.navigationBar.barStyle=UIBarStyleDefault;
        
        self.title=@"根视图";
        
        UIBarButtonItem* next = [[UIBarButtonItem alloc] initWithTitle:@"下一页" style:UIBarButtonItemStyleDone target:self action:@selector(preeNext)];
        
        
        
        self.navigationItem.rightBarButtonItem=next;
        
       
        
    }
    
    -(void)preeNext
    {
        //创建一个新的导航控制器
        
        VCSecond* vcSecond= [[VCSecond alloc]init];
        //使用当前视图控制器的导航对象
        [self.navigationController pushViewController:vcSecond animated:YES];
        
        
        
        
        
    }
    
    @end

    VCSecond.m

    #import "VCSecond.h"
    #import "VCThird.h"
    @interface VCSecond ()
    
    @end
    
    @implementation VCSecond
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.view.backgroundColor=[UIColor greenColor];
        self.title=@"视图二";
        UIBarButtonItem* btnNext=[[UIBarButtonItem alloc]initWithTitle:@"第三级" style:UIBarButtonItemStyleDone target:self action:@selector(pressNext)];
        
        self.navigationItem.rightBarButtonItem=btnNext;
        
        
    }
    
    -(void)pressNext
    {
        VCThird* vcThired=[[VCThird alloc]init];
        
        [self.navigationController pushViewController:vcThired animated:YES];
        
        
    }

    VCThird.m

    #import "VCThird.h"
    
    @interface VCThird ()
    
    @end
    
    @implementation VCThird
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.view.backgroundColor=[UIColor redColor];
        self.title=@"视图三";
        UIBarButtonItem* btnleft = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleDone target:self action:@selector(pressroot)];
        
        self.navigationItem.leftBarButtonItem=btnleft;
        
        
    }
    
    
    -(void)pressroot
    {
        [self.navigationController popToRootViewControllerAnimated:YES];
        
    }
    
    -(void)pressback
    {
        //将当前视图控制器弹出返回上一级界面
        [self.navigationController popViewControllerAnimated:YES];
    }
  • 相关阅读:
    使用NPOI导入导出标准Excel
    winform ListView应用之分组、重绘图标、网格线
    在网页中显示CHM
    动态表单(javascript实现)
    批量上传文件时,js验证文件名不能相同
    IE开发人员工具无法使用
    卸载方法 gnu grub version 0.97
    VS.Net 2003/VC6.0常用快捷键集合
    SQL SERVER 与ACCESS、EXCEL的数据转换
    通用获取父节点/子节点/子节点下所有节点ID的存储过程
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13747057.html
Copyright © 2020-2023  润新知