gpt4 book ai didi

ios - 来自 UITableViewCell 中的按钮的 UIPopoverPresentationController

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

在我的应用程序中,我有一个 UITableView,它的一个单元格中有一个 UIButton。这个按钮有一个 Action :

    - (IBAction)showPopover:(UIButton *)sender    
{
ChoseOptionsViewController *contentController = [[ChoseOptionsViewController alloc] init];
contentController.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *copvc = contentController.popoverPresentationController;
copvc.permittedArrowDirections = UIPopoverArrowDirectionAny;
copvc.sourceView = self.view;
copvc.sourceRect = sender.bounds;
contentController.preferredContentSize = CGSizeMake(200, 200);
[self presentViewController:contentController animated:YES completion:nil];
}

问题在于 sender.bounds 不返回任何内容,因此弹出窗口显示在 self.view 的左上角,而不是按钮的旁边。提前致谢。

最佳答案

尝试将您的 sourceView 更改为 sender:

copvc.sourceView = sender;

关于ios - 来自 UITableViewCell 中的按钮的 UIPopoverPresentationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26450331/

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