zoukankan      html  css  js  c++  java
  • iOS页面跳转

    以FirstViewController(FVC)的按钮button点击后跳转到SecondViewController(SVC)为例。
     
    1.StoryBoard 的segues方式
    鼠标点击按钮button然后按住control键拖拽到SVC页面,在弹出的segue页面中选择跳转模式。
     
    2.导航控制器UINavigationController
    1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions  
    2. {  
    3.     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];  
    4.     // Override point for customization after application launch.  
    5.     self.window.backgroundColor = [UIColor whiteColor];  
    6.     RootViewController *root = [[RootViewController alloc]init];  
    7.     UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:root];//先将root添加在navigation上  
    8.     [_window setRootViewController:nav];//navigation加在window上        
    9.     [self.window makeKeyAndVisible];  
    10.     return YES;  
     
    1. - (void)clicked{  
    2.     SecondViewController *second = [[SecondViewController alloc]init];  
    3.     [self.navigationController pushViewController:second animated:YES];  
    4. }  
     
    3.选项卡UITabbarController

    通过调用UITabBarController的addChildViewController方法添加子控制器,代码实例如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    UITabBarController *tabbarVC = [[ UITabBarController alloc ] init ];
    FirstViewController *FVC = [[FirstViewController ] init ];
    FVC.tabBarItem.title = @"控制器1" ;
    FVC.tabBarItem.image = [ UIImage imageNamed : @"first.png" ];
    SecondViewController *SVC = [[SecondViewController ] init ];
    SVC.tabBarItem.title = @"控制器2" ;
    SVC. tabBarItem.image = [UIImage imageNamed : @"new.png" ];
    // 添加子控制器(这些子控制器会自动添加到UITabBarController的 viewControllers 数组中)
    [tabbarVC addChildViewController :FVC];
    [tabbarVC addChildViewController :SVC];
     
     
     
     
     
  • 相关阅读:
    直播源列表
    MySQL为什么"错误"选择代价更大的索引
    C#中ConfigureAwait的理解(作者Stephen)
    理解C#中的 async await
    C#中Task.Delay() 和 Thread.Sleep() 区别
    扁平结构数据变成嵌套结构数据(树状结构)
    判断两个数组相同 两个对象相同 js
    嵌套结构数据(树状结构)变成扁平结构不带子元素(children)
    嵌套结构数据(树状结构)变成扁平结构带有子元素(children)
    2022.1.11学习日志
  • 原文地址:https://www.cnblogs.com/wangqi327/p/5526817.html
Copyright © 2011-2022 走看看