简体   繁体   English

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

[英]Presenting Modal View Controller in iOS not working

I need to show another view from rootviewcontroller on button click. 我需要在按钮点击时显示rootviewcontroller的另一个视图。 I have written the following code but it doesnt work. 我写了下面的代码,但它不起作用。 Any ideas why? 有什么想法吗?

In my app delegate method i have the following code - 在我的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;
}

Then in my mainviewcontroller i have a button action which is supposed to take me to a different class but it does nothing. 然后在我的mainviewcontroller中我有一个按钮动作,它应该把我带到另一个类,但它什么也没做。 Although the button action is working since nslog statements work. 虽然按钮操作正在运行,因为nslog语句有效。 Any ideas? 有任何想法吗?

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

如果你试试 :

[self presentModalViewController:loginViewController animated:YES];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM