我是iPhone SDK开发新手,我不是英国人,所以我对我的关卡表示歉意。exc_bad_access dismissModalViewControllerAnimated
这里是我的问题: 我有一个tabBarcontroller,有3项,每个人都有一个navBarcontroller
[self.loginViewController release];
[self setLoginViewController:[[LoginViewController alloc] init]];
[[self loginViewController] setDelegate:self];
[[self loginViewController] isLoggued];
self.tabBarController = [[UITabBarController alloc] init];
_FirstViewController = [[[FirstViewController alloc] init] autorelease];
_FirstViewController.title = @"title 1";
UINavigationController* navController1 = [[[UINavigationController alloc]
initWithRootViewController:_FirstViewController] autorelease];
_SecondViewController = [[[SecondViewController alloc] init] autorelease];
_SecondViewController.title = @"title 2";
UINavigationController* navController2 = [[[UINavigationController alloc]
initWithRootViewController:_SecondViewController] autorelease];
_ThirdViewController = [[[_ThirdViewController alloc] init] autorelease];
_ThirdViewController.title = @"title 3";
UINavigationController* navController3 = [[[UINavigationController alloc]
initWithRootViewController:_ThirdViewController] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navController1, navController2, navController3, nil];
[self.window addSubview:self.tabBarController.view];
// adds the tab bar's view property to the window
[self.window makeKeyAndVisible];
[self.tabBarController release];
if ([self respondsToSelector:@selector(loginViewControllerLogout:)]) {
[self performSelector:@selector(loginViewControllerLogout:) withObject:[self loginViewController]];
}
return YES;
这儿,这是选择
-(void)loginViewControllerLogout:(LoginViewController *)loginViewController {
if (![self.loginViewController logguedIn])
[self.tabBarController presentModalViewController:self.loginViewController animated:YES];
}
,当我loggued,我致电:
-(void)loginViewControllerDidFinish:(LoginViewController *)loginViewController {
[self.loginViewController dismissModalViewControllerAnimated:YES];
}
这段代码在应用程序启动时为冷杉时间。 LoginViewController显示>登录成功> LoginViewcontroller关闭> FirstViewController显示。 但是如果我去第三个控制器,点击注销: 选择器LoginViewControllerLogout调用> LoginViewController显示>登录成功>在dismissModal中崩溃。
没有错误堆栈,只是exc_bad_access错误。 loginViewController有多个保留。
在此先感谢
编辑:所有的功能都在AppDelegate中
就像我对比尔说,我不能这样做怎么把自我是我的AppDelegate *,所以不存在“self.view” ......感谢您的回复 – Boubou95
但是,你只会调用呈现内解雇查看,这不会是你的AppDelegate。在这里调用它,而不是回叫你的AppDelegate去做。 –
同样的事exc_bad_access。在我的AddDelegate中,我使用:[self dismissModalViewControllerAnimated:YES]在loginViewController中调用一个函数。 – Boubou95