0
Interface Builderの助けを借りずに空のテンプレートにコントローラを使用して独自のビューを作成する必要があります。私はAppDelegateで何を書く必要がありますか?空のテンプレートで表示
Interface Builderの助けを借りずに空のテンプレートにコントローラを使用して独自のビューを作成する必要があります。私はAppDelegateで何を書く必要がありますか?空のテンプレートで表示
XCode - >新規プロジェクト - >ウィンドウベースのテンプレートを選択します。その後、Info.plistからリソースからMainWindow.xibを削除します。このキーを削除します。 "メインNibファイルのベース名"。main.mファイルにあります。 int retVal = UIApplicationMain(argc、argv、nil、@ "AppDelegate"); // 4番目のパラメータはAppDelegateの名前です。あなたのAppDelegate.hでIBを使用していないIBOutlet UIWindowのプロパティを削除する/合成する..
// In your AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window makeKeyAndVisible];
// In your AppDelegate.h AnotherViewController* mainViewController;
mainViewController = [[AnotherViewController alloc] init];
[[mainViewController view] setFrame:[UIScreen mainScreen].applicationFrame];
[window addSubView:[mainViewController view]];
}
// In your AnotherViewController implement
- (void)loadView
{
// Lets say you have a UITableView
UITableView* tableView = [[[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain] autorelease];
[self setView:tableView];
}
これは変種が機能していない...テストできますか? – OdNairy
うまくいかない。私は自分のコードを更新しました。 AnotherViewController * mainViewControllerはiVarとして宣言します。そのviewControllerのloadViewメソッドを説明しました – 0x8badf00d