zoukankan      html  css  js  c++  java
  • 59.加载Viewcontroller的几种方法(添加导航,解决xib里面空间不显示问题)

    // 一、根据StoryboardID(需要在Storyboard设置),通过ViewController所在的Storyboard来加载:
    
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"FicowVC"];

    
    

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

        UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"FicowVC"];

        

        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];

        self.window.rootViewController = nav;

        [self.window makeKeyAndVisible];

        

        return YES;

    }




    // 二、通过UIViewController对应的.xib文件加载:
    UIViewController *vc = [[UIViewController alloc] initWithNibName:@"FicowVC" bundle:nil];
    
    
    
    
    // 三、直接加载UIViewController类:
    UIViewController *vc = [[UIViewController alloc] init];
    
    
    
    /*
    注意:
    loadNibNamed和initWithNibName需要加载的xib文件是不一样的。
    initWithNibName需要加载的xib文件的File Owner应改是需要加载的类,
    而loadNibNamed需要加载的xib文件的File Owner为NSObject。
    */
  • 相关阅读:
    ios10 获取idfa的坑
    iOS 获取手机sim卡的运营商(移动,电信,联通) 相关信息
    iOS获取手机IP地址
    UIScrollView 与 touchesBegan 冲突解决方法
    32位与64位基础
    MySQL数据库基础_表&简单查询
    MySQL数据库基础
    Java_File、递归
    Java_lambda表达式
    Java线程锁,等待唤醒和线程池
  • 原文地址:https://www.cnblogs.com/qiangzheVSruozhe/p/9395756.html
Copyright © 2011-2022 走看看