gpt4 book ai didi

ios - 在自定义单元格中的按钮中设置标签时出现异常

转载 作者:行者123 更新时间:2023-11-29 03:22:23 25 4
gpt4 key购买 nike

我已将方法 cellForRowAtIndexPath 中的标记设置为

cell.noOfCommentsButton.tag=indexPath.row; 其中 noOfCommentsButton 是我的 UIButton。

我已将此按钮的 IBAction 定义为:

- (IBAction)showComments:(BlogCell *)sender{
int tag=[(UIButton *)sender.noOfCommentsButton tag];
NSLog(@"The tag clicked:%d",tag);
}

Blogcell 是自定义单元格的类。

但是我在行 NSLog(@"The tag clicked:%d",tag); 上遇到异常,我不确定为什么。

最佳答案

  • (IBAction)showComments:(BlogCell *)sender{

这是错误的 - sender 是按钮,而不是单元格。所以应该是:

- (IBAction)showComments:(UIButton *)sender {

关于ios - 在自定义单元格中的按钮中设置标签时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20920392/

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