iOS手动加载控制器xib与指定加载控制器xib的状况分析

手动加载xib与指定加载xib的状况分析

1.指定加载xib
  • 1.图片的操做过程!git

  • 2.代码github

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window=[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
        UIViewController *vc=[[UIViewController alloc]initWithNibName:@"vc" bundle:nil];
        //ViewController *vc=[[ViewController alloc]initWithNibName:nil bundle:nil];
        //ViewController *vc=[[ViewController alloc]init];
        self.window.rootViewController=vc;
        [self.window makeKeyAndVisible];
        return YES;
    }
2.当不指定加载哪一个xib时(版本9.2)
  • 1.图片
  • 意思以下:
    • 当没有指定加载哪一个xib时的优先级,而且没有重写loadView时app

    • 在本例中是这样的:当图片中三个xib都存时,默认是加载带controller.xib,也就三者的优先级就出现了.net

    • 当只其中两个的时候,参考第二条,若是没有controller.xib,会加载View.xib3d

    • 代码code

      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
          self.window=[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
      //    UIViewController *vc=[[UIViewController alloc]initWithNibName:@"View" bundle:nil];
          //ViewController *vc=[[ViewController alloc]initWithNibName:nil bundle:nil];
          ViewController *vc=[[ViewController alloc]init];
          self.window.rootViewController=vc;
          [self.window makeKeyAndVisible];
          return YES;
      }
3.github
相关文章
相关标签/搜索