试试这个代码:
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:completion
和dismissViewControllerAnimated:completion