0
Interface Builder의 도움없이 빈 템플릿에 컨트롤러로 내 자신의보기를 만들어야합니다. AppDelegate에서 작성해야하는 것은 무엇입니까?빈 템플릿에서보기
Interface Builder의 도움없이 빈 템플릿에 컨트롤러로 내 자신의보기를 만들어야합니다. AppDelegate에서 작성해야하는 것은 무엇입니까?빈 템플릿에서보기
XCode -> 새 프로젝트 -> 창 기반 템플릿 선택. 그런 다음 리소스에서 MainWindow.xib를 제거하고 info.plist에서 "Main Nib file base name"을 제거합니다. main.m 파일에서 int retVal = UIApplicationMain (argc, argv, nil, @ "AppDelegate"); // 네 번째 매개 변수는 AppDelegate의 이름입니다. 당신의 AppDelegate.h에서
// 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];
}
그것은 변형이 작동하지 ... 당신이 그것을 테스트 할 수 않는 것 .. 당신은 모든 IB를 사용하지 않는로 함께 IBOutlet UIWindow에 대한 합성/속성을 제거? – OdNairy
작동하지 않습니다. 내 코드를 업데이트했습니다. AnotherViewController * mainViewController는 iVar로 선언합니다. 그 viewController의 loadView 메소드를 보여줬다. – 0x8badf00d