1.砍掉storyboard和launchScreen
2.清掉
3.appdelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
self.viewController = [[MyViewController alloc] initWithNibName:nil bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible]; return YES;
}
這邊
self.viewController = [[MyViewController alloc] initWithNibName:nil bundle:nil];
nibname可以先填入xib檔案的字串,但是,如此一來,controller就和特定的一個xib對應到了
如果想要動態對應,可以在controller.m裡面:
4.
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
// self = [super initWithNibName:@"MyViewController" bundle:nibBundleOrNil];
self = [super initWithNibName:@"Green" bundle:nibBundleOrNil];
return self;
}
利用這邊才確定會對應到哪一個xib,
5.一般,如果產生controller可以直接產生對應的xib,但是如果我是要產生很多新的xib,動態對應controller呢!?
先產生新的xib:
點到file owner,給他對應的controller,(就是說,很多的xib,可以有同一個controller)
,然後最右邊的connection inspector,把view做連線
基礎設置就到這
沒有留言:
張貼留言