gpt4 book ai didi

ios - 如何使用 Storyboard从自定义 uitableviewcell 正确启动 popover segue

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:26:20 24 4
gpt4 key购买 nike

那么当打开它的按钮位于 TableView 中的自定义原型(prototype)单元格内时,如何使用 Storyboard 正确设置弹出框 segue?

  1. 它应该可以在 iphone 和 ipad 上运行
  2. 它应该在 ipad 上有正确的位置和 anchor

最佳答案

我认为最优雅的解决方案如下:

像往常一样从按钮创建一个 segue 到适当的 ViewController

打开 segue 并将 anchor 设置到 TableView (从圆圈拖动到 View )。

在准备 segue 添加以下内容:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
UIViewController *vc = (UIViewController *)segue.destinationViewController;
UIPopoverPresentationController *ppc = vc.popoverPresentationController;
UIButton *button = (UIButton *)sender;
ppc.sourceRect = button.frame;
ppc.sourceView = button.superview;
}

关于ios - 如何使用 Storyboard从自定义 uitableviewcell 正确启动 popover segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29331292/

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