gpt4 book ai didi

ios - 当我单击 UITableViewCell 中的按钮时,UITableView 不会调用 didSelectRowAtIndexPath 函数

转载 作者:行者123 更新时间:2023-11-28 19:35:26 26 4
gpt4 key购买 nike

我有一个按钮,它在 UITableViewCell 中有一个单选按钮作为图像。当我单击该按钮时,它会变成选中的单选按钮或未选中的单选按钮。这是可行的,但问题是它不会触发 didSelectRowAtIndexPath。它仅在我单击行上的空闲位置时触发该功能。我试过 UITapGestureRecognizer 但它也不起作用。我怎样才能解决这个问题?

感谢您的帮助。

最佳答案

根据我的理解,您希望在按钮和行选择上具有相同的功能,

如果是真的,我知道一些方法,

  1. 在按钮事件上手动调用 didSelectRowAtIndexPath 方法。

    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:ROW_YOU_WANT_TO_SELECT inSection:SECTION_YOU_WANT_TO_SELECT]
    [self tableView:YOUR_TABLE didSelectRowAtIndexPath:indexPath];

    并在 didSelectRowAtIndexPath 中拥有您的功能。

  2. 从 Button 中删除操作目标并在单元格上设置 TapGestureRecogniser。

关于ios - 当我单击 UITableViewCell 中的按钮时,UITableView 不会调用 didSelectRowAtIndexPath 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39412078/

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