Xcode5でデフォルトで生成されるStoryBoardって、デフォルトで消せないの?
Single View Applicationを作成するときに、「Use StoryBoard」のようなチェックボックスがあるのかと思ったら、見当たらないですね:(
なので勝手にStoryBoardが作られてしまいます:(
今のところ消し方分かりません:(
代替え案として
1.Empty Applicationを作成する。
2.Single View Applicationを作成した後StoryBoardを削除し、適当なViewControllerを表示させる。
を採用しています。
詳細! Objective-C iPhoneアプリ開発 入門ノート Xcode5+iOS 7対応
- 作者: 大重美幸
- 出版社/メーカー: ソーテック社
- 発売日: 2013/11/02
- メディア: 単行本
- この商品を含むブログを見る
1.Empty Applicationを作成する。
これはそのままですね。
プロジェクト生成後はUIViewControllerのサブクラスを適当に作成して、AppDelegate.m内でインスタンスを生成してあげてそれを表示するという流れになると思います。
2.Single View Applicationを作成した後StoryBoardを削除する。
ここではとりあえず"SingleViewTest"というプロジェクト名を使っています。
プロジェクトを新規作成しSingle View Applicationのテンプレートを選択したら、多分以下の様なファイル構成になっていると思います。
"Main.storyboard"を削除します(いつもMove to Trashにしてます)。
Supporting Filesディレクトリ内にSingleViewTest-Info.plistがあるので、"Main storyboard file base name"という項目を削除します(丸いマイナスボタンをクリック)。
ここでひとまずビルドしてみます。
多分成功します。
多分…。
あとは以下のようにソースコードを修正してやれば…
AppDelegate.m
#import "AppDelegate.h" #import "ViewController.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.rootViewController = [[ViewController alloc] init]; [self.window makeKeyAndVisible]; return YES; } @end
ViewController.m
#import "ViewController.h" @interface ViewController () @end @implementation ViewController -(id)init{ if(self = [super init]){ self.view.backgroundColor = [UIColor orangeColor]; CGRect button_rect = CGRectMake(0, 0, 100, 50); UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button setBounds:button_rect]; [button setTitle:@"alert" forState:UIControlStateNormal]; [button addTarget:self action:@selector(showAlert) forControlEvents:UIControlEventTouchUpInside]; [button setCenter:CGPointMake(self.view.center.x, 100)]; [self.view addSubview:button]; } return self; } -(void)showAlert{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"OBJC" message:@"Hello, World!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } @end
できましたね:)
- 作者: 荻原剛志
- 出版社/メーカー: ソフトバンククリエイティブ
- 発売日: 2011/12/28
- メディア: 大型本
- 購入: 14人 クリック: 98回
- この商品を含むブログ (20件) を見る