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 に答える