0

我从 iPad 应用程序的 UISplitVC 中的 MasterViewController 调用此代码:

-(void)viewWillAppear:(BOOL)animated{
//PRESENT MODALVC
ModalViewController *modalVC = [[ModalViewController alloc] initWithNibName:@"ModalViewController" bundle:nil];
[self setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:modalVC animated:YES];

}

但它不起作用。没有出现 ModalVC。

4

1 回答 1

1

试试这个代码:

ModalViewController *modalVC = [[ModalViewController alloc] initWithNibName:@"ModalViewController" bundle:nil];
[modalVC setModalPresentationStyle:UIModalPresentationFullScreen]; //You set the presentation style of the controller that would be presented, not the presenting controller
//This check is needed, because presentModalViewController:animated is depreciated in iOS5.0 and presentViewController:animated:completion must be used instead. The same is valid for dismissModalViewControllerAnimated and dismissViewControllerAnimated:completion
if([self respondsToSelector:@selector(presentViewController:animated:completion:)])
    [self presentViewController:modalVC animated:YES completion:nil];
else
    [self presentModalViewController:modalVC animated:YES];

如果您的目标是 iOS5.0+,则不需要此检查,您应该只使用presentViewController:animated:completiondismissViewControllerAnimated:completion

于 2012-06-07T03:26:20.150 回答