【发布时间】:2012-01-30 15:08:41
【问题描述】:
我有一个 iOS 5 应用程序。 当我想将视图推送到导航控制器时,应用程序崩溃:(
这是我的 appDelegate 部分:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.navigationController=[[UINavigationController alloc] init];
StartViewController *startViewController=[[StartViewController alloc] init];
[self.navigationController pushViewController:startViewController animated:YES];
[self.navigationController setNavigationBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController=self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
这是我推新视图控制器的方法:
-(IBAction)startPressed:(id)sender
{
NSLog(@"startPressed: called");
//loading RootViewController (mainscreen view)
RootViewController *rootViewController=[[RootViewController alloc] init];
[self.navigationController pushViewController:rootViewController animated:YES];
}
应用程序在字符串 [self.navigationController pushViewController:rootViewController animated:YES]; 处崩溃
请帮帮我。如何解决这个问题?
【问题讨论】:
-
你的有问题,看我的回答。但请提供崩溃日志。
-
我认为处理自动引用计数模式有问题。我想我错过了什么。这是我第一个启用了自动引用计数模式的 ios 5 应用程序
-
应用程序非常简单。我的 startViewController 中只有一个按钮启动。当用户按下它时,我正在尝试加载 RootViewController。但是应用程序崩溃了:(
标签: iphone objective-c ios uinavigationcontroller pushviewcontroller