我有ViewController(Passwordviewcontroller),我想用"presentModalviewController"来显示
我有一个AppDeleage:- (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 = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
这里是我的ViewController,我想从PasswordviewController显示:
-ViewDidLoad
{
self.passwordView = [[PasswordView alloc]initWithNibName:@"PasswordView" bundle:nil];
[passwordView setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:passwordView animated:YES];
}
我什么都试过了,但还是不行,有人有主意吗?
把这个放在viewDidAppear
而不是viewDidLoad
。在viewDidLoad
中,视图可能会加载到内存中,但不必在屏幕上显示。另一方面,在viewDidAppear
中,您的视图已准备好显示并以这样一种方式正确插入窗口,您可以显示模态视图。
编辑:根据注释将viewWillAppear
更改为viewDidAppear