在XCode4.2中添加MainWindow.xib文件
2013-01-07 11:10
453 查看
xcode4.2推荐使用storyboard,但网上资料太少,书上讲的也都是基于xib的
花了2天时间,终于把xib的helloWorld写出来了。
注意,类名一定要大写,为了这个东西,我搞了2天,在配viewContorller时一直抛错。
新建 Empty Application
添加一个object,添加一个View Controller,添加一个window,
把File's Owner的 custom class 改成 UIApplication
把Object的custom class 改成 自己的 delegate,我的是HelloAppDelegate
然后新建 Cocoa Touch 下的UIViewControllersubclass
拖一个label进去,写上hello world
然后,回到MainWindow中,把ViewController的custom class 改成HelloViewController
然后拖线:
File's Owner拖到 delegate,从delegate拖到viewcontroller和window
然后修改代理类里的
C代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
//self.window.backgroundColor = [UIColor whiteColor];
[self.window addSubview: self.viewController.view];
[self.window makeKeyAndVisible];
return YES;
}
运行即可~
花了2天时间,终于把xib的helloWorld写出来了。
注意,类名一定要大写,为了这个东西,我搞了2天,在配viewContorller时一直抛错。
新建 Empty Application
添加一个object,添加一个View Controller,添加一个window,
把File's Owner的 custom class 改成 UIApplication
把Object的custom class 改成 自己的 delegate,我的是HelloAppDelegate
然后新建 Cocoa Touch 下的UIViewControllersubclass
拖一个label进去,写上hello world
然后,回到MainWindow中,把ViewController的custom class 改成HelloViewController
然后拖线:
File's Owner拖到 delegate,从delegate拖到viewcontroller和window
然后修改代理类里的
C代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
//self.window.backgroundColor = [UIColor whiteColor];
[self.window addSubview: self.viewController.view];
[self.window makeKeyAndVisible];
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. //self.window.backgroundColor = [UIColor whiteColor]; [self.window addSubview: self.viewController.view]; [self.window makeKeyAndVisible]; return YES; }
运行即可~
相关文章推荐
- xcode 4.2 自己添加 MainWindow.xib
- IOS_xcode4.2手动添加MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode 4.2 自己添加 MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode 4.2 自己添加 MainWindow.xib
- xcode 4.2 自己添加 MainWindow.xib
- xcode4.2创建ios5 手动添加MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode4.2创建ios5 手动添加MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode4.2手动添加MainWindow.xib
- xcode 4.2 自己添加 MainWindow.xib
- iPhone开发笔记[15/50]:指定启动的主界面XIB文件,在xcode4.2里可以不指定MainWindow.xib了
- Xcode4.2自定义MainWindow.xib
- xcode4.2 MainWindow.xib
- MainWindow.xib absence in Xcode 4.2 beta 4 with iOS 5 SDK
- xcode4.2中使用xib来运行hello world (MainWindow.xib)
- xcode 添加mainWindow.xib
- MainWindow.xib absence in Xcode 4.2 beta 4 with iOS 5 SDK