gpt4 book ai didi

iphone - 带有 UIButton 的 UITableViewCell

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

我有 UITable,其中包含一些 UIButton。我想要一种使用该标签的方法。

我遇到的问题是我需要两个标签,一个用于检索tableviewCellWithReuseIdentifier和configureCell中的单元格。

直到最近,我一直在使用 UIButton.title 来确定我选择的表中的哪一行。 (不可见的)文本是行号。

现在我需要使用一些可见文本的标题。我怎样才能找到被按下的行?

当我按下按钮外部的区域时,通常的 didSelectRowAtIndexPath 被调用。困难的部分是我想捕获 UIButton (它调用它自己的选择器)行,这是我从标题中找到的。现在我需要其他东西的标题。

最佳答案

我用的是这样的东西。这将为您提供 TableView 中的索引路径。

- (IBAction)buttonAction:(id)sender {
UIButton *button = (UIButton *)sender;
CGPoint buttonOriginInTableView = [button convertPoint:CGPointZero toView:tableView];
NSIndexPath *indexPath = [tableView indexPathForRowAtPoint:buttonOriginInTableView];

// do something
}

关于iphone - 带有 UIButton 的 UITableViewCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3910823/

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