gpt4 book ai didi

ios - UIPopoverController 显示的 UIViewController 的大小类错误

转载 作者:可可西里 更新时间:2023-11-01 04:01:36 25 4
gpt4 key购买 nike

我正在开发具有通用 Storyboard的通用 iPhone/iPad 应用程序。对于某些 ViewController,如果它们在 iPad 上有一些特定的布局,我会使用大小类。

我有一个 ViewController 需要在 iPhone 上以模态方式呈现,但在 iPad 上它需要在 UIPopoverController 中显示。

UINavigationController *navigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"ComposeMessageNavigationController"];
ComposeMessageViewController *viewController = (ComposeMessageViewController *)navigationController.topViewController;
//Prepeare my view controlller
...

if (IS_IPAD) {
UIPopoverController * popover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
CGSize screenSize = [UIScreen mainScreen].bounds.size;
CGRect popoverFrame = CGRectMake(screenSize.width / 2, screenSize.height / 2, 1, 1);
[popover presentPopoverFromRect:popoverFrame inView:self.view permittedArrowDirections:0 animated:YES];
} else {
[self presentViewController:navigationController animated:YES completion:^{
}];
}

它工作得很好,但是 Size Classes 有问题。我在 wRegular/hRegular Size Class 的 Storyboard 上做了一些更改,但在 iPad 上的 UIPopoverController 中仍然显示 iPhone 布局。这是因为弹出框的尺寸小于 iPad 屏幕。我可以在 Interface Builder 中使用大小类进行更改以在 iPad 上的弹出窗口中显示它们但在 iPhone 上忽略它们吗?

最佳答案

在弹出 View Controller 上使用 setOverrideTraitCollection 应该允许您使用 iPad 的常规 x 常规。

关于ios - UIPopoverController 显示的 UIViewController 的大小类错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28028762/

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