私のコードには、多くのセクションがアルファベット順に並べられたテーブル ビューがあります。テーブルの行が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
.