OGeek|极客世界-中国程序员成长平台

标题: ios - 如何在单元格iOS中为按钮设置标签? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 14:41
标题: ios - 如何在单元格iOS中为按钮设置标签?

我尝试为单元格内的按钮设置 tag:

- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath {
     [cell.btnWithIdCell setTag: (int) self.responseObject[@"results"][indexPath.row][@"id"]];
}

在事件中单击按钮后,我尝试获取 tag:

- (IBAction)openid)sender {
    NSString* tagString = [NSString stringWithFormat"%d", [sender tag]];
}

它给了我错误的数字 tagString

如何从响应对象中为按钮设置标签?



Best Answer-推荐答案


在单元格中设置按钮标签:

cell.btnWithIdCell.tag = indexPath.row;

关于ios - 如何在单元格iOS中为按钮设置标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35507195/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4