gpt4 book ai didi

ios - 在 iPad 上以模态方式呈现 ModalViewController

转载 作者:行者123 更新时间:2023-11-29 04:37:13 25 4
gpt4 key购买 nike

我从 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。

最佳答案

试试这段代码:

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

关于ios - 在 iPad 上以模态方式呈现 ModalViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10925190/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com