zoukankan      html  css  js  c++  java
  • xcode 添加mainWindow.xib

    步骤:  

         1.创建空项目 Empty Application。(在Xcode4.2以后下创建的这个空项目不再有MainWindow.xib文件了。)

         2.Ctrl+N,创建User Interface下面的Window(选择“iOS->User Interface->Window),命名成MainWindow.xib(这名称可随意,只是以MainWindow我们更熟悉)。
         3.File Owner修改成UIApplication。(即调出show identity inspector面板,将file's Owner的属性Custom Class中将class改为UIApplication。



         4.从Library库中,拖个Object出来添加,并修改类为Delegate的那个类,最开始自动生成的那个。(即将新添加的Object的Class改为AppDelegate




         5.把Delegate类的属性window声明加上IBOutlet,这样才好在IB里面连接。(即将AppDelegate中UIWindow属性标记为IBOutlet

            即@property (strong,nonatomic) UIWindow *window;修改为:@property (strong, nonatomic) IBOutlet UIWindow *window;

        然后,把MainWindow.xib的FileOwner的delegate设置为你的AppDelegateFileOwner的delegate和AppDelegate(Object)连接:(蓝色连线哦)



           把Window和你AppDelegate中的Outlet关联起来:


    上图即AppDelegate的outlets和Window连接起来。
         6.(可以看到,已经有一个Window对象,此window对象就是iphone的屏幕。)把window属性连接到IB中默认出现的Window。
         7.给刚才的代理再加个@property (strong,nonatomic) IBOutlet  UITabBarController* rootController;属性。
         8.在IB中拖个TabBarController出来,并连接到前面的Object的rootController。
         9.在代理的didFinishLaunchingWithOptions函数中修改下

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

        {

            // Override point for customization after application launch.

            // self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

            [self.windowaddSubview:rootController.view];

            [self.windowmakeKeyAndVisible];

            return YES;

        }

        不需要再创建window,然后把rootcontrollerview添加到当前window下面就可以了。注释掉 -(BOOL)application:didFinishLaunchingWithOptions:方法中与我们从XIB加载相冲突的方法调用(self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];)

        10.关键一个步骤,打开项目属性,在Summary下面的Main Interface里面选择MainWindow完事。

  • 相关阅读:
    December 23rd 2016 Week 52nd Friday
    December 22nd 2016 Week 52nd Thursday
    December 21st 2016 Week 52nd Wednesday
    December 20th 2016 Week 52nd Tuesday
    December 19th 2016 Week 52nd Sunday
    December 18th 2016 Week 52nd Sunday
    uva294(唯一分解定理)
    uva11624Fire!(bfs)
    fzu2150Fire Game(双起点bfs)
    poj3276Face The Right Way
  • 原文地址:https://www.cnblogs.com/wangzh1225/p/3430638.html
Copyright © 2011-2022 走看看