gpt4 book ai didi

ios - UIPopover contentSize 在运行时发生变化

转载 作者:行者123 更新时间:2023-12-02 02:29:20 27 4
gpt4 key购买 nike

我们面临一个问题,即当弹出窗口内使用 UIActionSheet 样式的alertController 时,弹出窗口大小会发生变化。这是在我们升级代码库 iOS13 后发生的

示例代码:https://github.com/Sundeep-manne/UIPopover.git

最佳答案

我认为这是苹果的错误。我在 Xcode 11.1 上体验过它,但在 Xcode 11.2.1 上显示 ActionSheet 时出现崩溃:

*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController () of style UIAlertControllerStyleActionSheet from UINavigationController (). The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'

所以答案是:要在 iPad 上使用 ActionSheet,您需要在 UIAlertController 的 popoverPresentationController 中提供 sourceView 和 sourceRect。更多信息: https://medium.com/@nickmeehan/actionsheet-popover-on-ipad-in-swift-5768dfa82094

苹果文档:

On iPad, UIKit requires that you display an action sheet inside a popover.

https://developer.apple.com/documentation/uikit/windows_and_screens/getting_the_user_s_attention_with_alerts_and_action_sheets

关于ios - UIPopover contentSize 在运行时发生变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58008997/

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