gpt4 book ai didi

ios - 弹出 View Controller 显示为拉伸(stretch)且未调整大小

转载 作者:行者123 更新时间:2023-11-30 13:43:39 25 4
gpt4 key购买 nike

我正在尝试显示具有模式呈现样式的 View Controller - 弹出窗口。问题是 View Controller 显示为拉伸(stretch)的,并且没有调整自身大小以适应我设置的首选内容大小。

这是我用于显示 View Controller 的代码:

let vc = self......
vc.modalPresentationStyle = .Popover
vc.delegate = self
let popover = vc.popoverPresentationController
vc.preferredContentSize = CGSizeMake(360,291)
popover!.sourceView = self.topBarView
popover!.delegate = self
popover!.sourceRect = CGRectMake(0,145,0,0)
popover?.popoverBackgroundViewClass = CustomUIPopoverBackgroundView.self
self.presenetViewController(vc,animated:true,completion:nil)

CustomUIPopoverBackgroundView 有以下相关代码:

override class func contentViewInsets () -> UIEdgeInsets {
return UIEdgeInsets(top:0,left:0,bottom:0,right:0)
}

我将用屏幕截图更新帖子以说明问题所在。如果您需要任何其他详细信息,请告诉我。

谢谢

最佳答案

请注意,iPhone 不支持 PopOver 呈现样式,因为水平尺寸类别为紧凑(iPhone6+/S 上的横向方向是异常(exception))。正如 UIViewController 的文档中提到的:

  • UIModalPresentationPopover In a horizontally regular environment, a presentation style where the content is displayed in a popover view. The background content is dimmed and taps outside the popover cause the popover to be dismissed. If you do not want taps to dismiss the popover, you can assign one or more views to the passthroughViews property of the associated UIPopoverPresentationController object, which you can get from the popoverPresentationController property.

In a horizontally compact environment, this option behaves the same as UIModalPresentationFullScreen.

关于ios - 弹出 View Controller 显示为拉伸(stretch)且未调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35246761/

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