zoukankan      html  css  js  c++  java
  • 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];
    }
  • 相关阅读:
    ubuntu 14.04 firefox install flash-plugin
    ubuntu node.js Binaries方式安装(二进制文件安装)
    ubuntu14.04 截图
    ubuntu 14.04下,thinkpad触摸板关闭方法
    ubuntu Mozilla Firefox install flash plugin 火狐浏览器安装flash插件
    win7+ubuntu 14.04双系统 硬盘安装
    后台启动VirtualBox虚拟机
    excel vlookup函数使用方法
    图片添加文字水印和图片水印
    记录使用Stream转多层map数据结构及遇到的坑
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13747057.html
Copyright © 2011-2022 走看看