tôi phải đối mặt với một vấn đề tương tự mà tôi muốn hộp kiểm tùy chỉnh để xuất hiện trong chế độ Edit nhưng không phải là - nút xóa '()'.
Stefan's answer hướng tôi đi đúng hướng.
Tôi đã tạo nút chuyển đổi và thêm nút này làm chỉnh sửaAccessoryView vào Ô và kết nối nó với phương thức.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
....
// Configure the cell...
UIButton *checkBoxButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 40.0f, 32.0f)];
[checkBoxButton setTitle:@"O" forState:UIControlStateNormal];
[checkBoxButton setTitle:@"√" forState:UIControlStateSelected];
[checkBoxButton addTarget:self action:@selector(checkBoxButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
cell.editingAccessoryType = UITableViewCellAccessoryCheckmark;
cell.editingAccessoryView = checkBoxButton;
return cell;
}
- (void)checkBoxButtonPressed:(UIButton *)sender {
sender.selected = !sender.selected;
}
thực hiện những phương pháp đại biểu
- (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleNone;
}
trình một cách hoàn hảo, cảm ơn! –
hoàn hảo .... cảm ơn bạn. – CKT
tốt nhất + cho công việc tốt đẹp – Warewolf