gpt4 book ai didi

ios - io8 如何设置 UIPopoverPresentationController 大小

转载 作者:技术小花猫 更新时间:2023-10-29 10:48:42 25 4
gpt4 key购买 nike

我设置了 UIPopoverPresentationController 来显示 UIViewController 和 UIAlertView 显示。

但是当我创建自定义的 UIViewController 并使用 UIPopoverPresentationController 时。有显示全屏。

我想建立这样的效果 http://cocoa.tumblr.com/post/92070238973/how-can-i-use-both-uipopoverpresentationcontroller

我曾尝试设置 preferredContentSize,但它仍然显示全屏。

我的代码如下:

 - (void)viewDidLoad {
[super viewDidLoad];
contentVC = [UIViewController new];
contentVC.view.backgroundColor = [UIColor darkGrayColor];
contentVC.preferredContentSize = CGSizeMake(200, 200);


UIPopoverPresentationController *popPC = contentVC.popoverPresentationController;
popPC.delegate = self;
popPC.sourceView = self.view;
popPC.sourceRect = CGRectMake(0,0,0,0);
popPC.permittedArrowDirections = UIPopoverArrowDirectionAny;
}

- (IBAction)btnAction:(id)sender {

[self presentViewController:contentVC animated:NO completion:ni

}

-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
return UIModalPresentationOverCurrentContext;
}

有谁知道如何在uiviewcontroller和UIPopoverPresentationController中设置size,比如网页效果?

我将在 UIViewController 中设置其他组件(现在只设置背景颜色)。

非常感谢。

最佳答案

在 Storyboard 中选择导航 Controller 并设置内容大小值。

enter image description here

这也可以通过继承 UINavigationController 并设置 preferredContentSize 在代码中完成。

- (void)viewDidLoad {
[super viewDidLoad];
self.preferredContentSize = CGSizeMake(100, 100);
}

关于ios - io8 如何设置 UIPopoverPresentationController 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28709136/

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