我很长一段时间一直是这个网站的忠实粉丝,但这是我发布的第一个问题.
我已经阅读了与主题相似的每个帖子(我认为),但他们都使用NIB文件. 我的项目中的任何地方都没有nib文件.
这是一个带有一个视图的简单项目(这意味着一个委托类,一个uiviewcontroller类和一个uiview类),我的视图显示正常,除了从未调用viewDidLoad方法.
main.m看起来像这样:
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"MyAppDelegate");
[pool release];
return retVal;
}
Run Code Online (Sandbox Code Playgroud)
MyAppDelegate.m看起来像这样:
-(void)applicationDidFinishLaunching:(UIApplication *)application{
UIWindow *localWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = localWindow;
[localWindow release];
MainViewController *viewController = [[MainViewController alloc] init];
//Option 1
navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
////Option 2
//navigationController = [[UINavigationController alloc] init];
//navigationController.viewControllers = [NSArray arrayWithObject:viewController];
////Option 3
//navigationController = [[UINavigationController alloc] init];
//[navigationController pushViewController:viewController animated:NO]; …Run Code Online (Sandbox Code Playgroud)