1 如果要使用XIB进行UI的绘制,我们先要删掉Main.storyboad
2
3 修改AppDelegate 代码
(1) AppDelegate.h 修改成
#import <UIKit/UIKit.h>
#import "MainViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;//默认有的
@property (strong, nonatomic) MainViewController *viewController;//你自己定义的控制器
@end
(1) AppDelegate.m 修改 didFinishLaunchingWithOptions 方法
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//创建Window 并初始化窗口大小,
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
//初始化该视图控制器关联用户UI
self.viewController = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil];
//该窗口与视图关联用户UI
self.window.rootViewController = self.viewController;
//该UIWindow 对象设为主窗口,并显示出来
[self.window makeKeyAndVisible];
return YES;
}