我有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;
}
这是我希望PasswordviewController显示的My ViewController:
-ViewDidLoad
{
self.passwordView = [[PasswordView alloc]initWithNibName:@"PasswordView" bundle:nil];
[passwordView setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:passwordView animated:YES];
}
我尝试了一切,但仍然无法正常工作,有人有想法吗?
答案 0 :(得分:0)
将其放在viewDidAppear
而非viewDidLoad
中。在viewDidLoad
中,您的视图可能会加载到内存中,但不一定要在屏幕上显示。另一方面,在viewDidAppear
中,您的视图已准备好显示在窗口中正确插入,以便您可以显示模态视图。
修改:根据评论
将viewWillAppear
更改为viewDidAppear