我的应用程序开始于LoginViewController
. 登录视图有一个“注册”按钮,代码如下所示。如果我点击注册,当应用程序启动时,什么也没有发生。但是,如果我登录并注销,则注册按钮可以正常工作。
发生这种情况应该是什么问题?
应用委托:
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
//Load View Controllers;
self.vcClubs = [[[ClubsViewController alloc] init] autorelease];
self.vcParties = [[[PartiesViewController alloc] init] autorelease];
self.vcEditProfile = [[[EditProfileViewController alloc] init] autorelease];
self.navClubs = [[[UINavigationController alloc] initWithRootViewController:self.vcClubs] autorelease];
self.navClubs.navigationBarHidden = YES;
self.navParties = [[[UINavigationController alloc] initWithRootViewController:self.vcParties] autorelease];
self.navParties.navigationBarHidden = YES;
// Load Login View
UIViewController *loginView = [[[LoginViewController alloc] init] autorelease];
self.window.rootViewController = loginView;
[self.window makeKeyAndVisible];
return YES;
}
...
- (void)login
{
self.vcMenu = [[[MenuViewController alloc] init] autorelease];
self.vcLocationMenu = [[[LocationMenuViewController alloc] init] autorelease];
self.mainController = [[[MainViewController alloc] init] autorelease];
self.mainController.leftViewController = self.vcMenu;
self.mainController.rightViewController = self.vcLocationMenu;
[self.mainController setMainViewController:self.navParties];
[self.mainController showMainViewControllerAnimated:YES];
self.window.rootViewController = self.mainController;
CATransition *transition = [[[CATransition alloc] init] autorelease];
transition.duration = 1;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromBottom;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[self.window.layer addAnimation:transition forKey:@"login"];
}
...
登录控制器.php:
...
- (IBAction)onTapSignupButton:(id)sender
{
RegisterViewController *controller = [[[RegisterViewController alloc] init] autorelease];
[self.navigationController pushViewController:controller animated:YES];
NSLog(@"%@", self.navigationController);
}
...
在应用启动时返回 NSLOG:
2013-02-18 02:18:29.986 App[32652:c07] (null)