1.
(プロジェクト名)AppDelegate.mファイルの、application:didFinishLaunchingWithOptionsメソッドで、UIWindowとUIViewController(を継承したRootViewController)を作成してUIWindowに追加する。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
RootViewController *viewController = [[RootViewController alloc] init];
navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[viewController release];
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
}
2.
UIViewCOntrollerクラスのloadViewをオーバーライドして、self.viewにviewを追加する。
-(void)loadView{
CGRect bounds = [[UIScreen mainScreen] applicationFrame];
UIView *contentView = [[UIView alloc] initWithFrame:bounds];
contentView.backgroundColor = [UIColor redColor];
self.view = contentView;
[contentView release];
}
参考PDF:iPhone OS View Controller プログラミングガイド プログラムによるビューの作成
0 件のコメント:
コメントを投稿