gpt4 book ai didi

iphone - IOS中获取UITableView的行号

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:03:36 26 4
gpt4 key购买 nike

<分区>

在我的代码中,我有一个 TableView ,其中许多部分按字母顺序排序。我在表行中有 checkboxes(UIButton),我需要根据行中输入的各自状态检查它们。我做过

checkbutton.tag = indexpath.row; 

但是当表格滚动和部分发生变化时,我在我的复选框方法中获得了上一节的状态。任何人都请帮助我。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CheckButton = [UIButton buttonWithType:UIButtonTypeCustom];
[CheckButton addTarget:self action:@selector(CheckBoxAction:) forControlEvents:UIControlEventTouchUpInside];
CheckButton.tag=indexPath.row;
//some other stuff
[cell.contentView addSubview:CheckButton];
}

这是我的 CheckBoxAction

-(void)CheckBoxAction:(UIButton *)btn
{
tag = btn.tag;
NSDictionary *tagdict =[statusArray objectAtIndex:tag];
}

现在,问题是当部分更改时 indexpath.row 为 0,因此我无法在我的 CheckBoxAction 中访问确切的行号。

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