在iOS中呈现模态视图控制器不起作用

时间:2012-07-13 15:23:50

标签: iphone objective-c ios uiviewcontroller presentmodalviewcontroller

我需要在按钮点击时显示rootviewcontroller的另一个视图。我写了下面的代码,但它不起作用。有什么想法吗?

在我的app委托方法中,我有以下代码 -

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController" bundle:nil] autorelease];

self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}

然后在我的mainviewcontroller中我有一个按钮动作,它应该把我带到另一个类,但它什么也没做。虽然按钮操作正在运行,因为nslog语句有效。有任何想法吗?

   LoginViewController * loginViewController = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:nil];
   [self.modalViewController presentModalViewController:loginViewController animated:YES];
NSLog(@"HE::P");

1 个答案:

答案 0 :(得分:2)

如果您尝试:

[self presentModalViewController:loginViewController animated:YES];
相关问题