0
我有一個tableview和一個單元格:D與選擇披露附件。我用故事板創建了所有UI元素。 (沒放視圖中單元格的內容) 我使用SWTableViewCell實現刷卡只是到刪除,但一切似乎都做工精細,除了當我把一個斷點上的方法刷卡刪除
#pragma mark -SWTableViewDelegate-
-(void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index
{
NSIndexPath *path=[self.table indexPathForCell:cell];
[anArray removeObjectAtIndex:path.row];
[self.table deleteRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationRight];
}
,這將有助於你明白我只是在這裏做
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
SWTableViewCell *cell=(SWTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
if (!cell)
{
NSMutableArray *rightUtilityButtons = [NSMutableArray new];
[rightUtilityButtons sw_addUtilityButtonWithColor:[UIColor colorWithRed:1.0f
green:0.231f
blue:0.188
alpha:1.0f]
title:@"Delete"];
cell = [[SWTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell" containingTableView:_table leftUtilityButtons:nil rightUtilityButtons:rightUtilityButtons];
}
NSMutableDictionary *deDict=[[NSMutableDictionary alloc]initWithDictionary:[anArray objectAtIndex:indexPath.row]];
cell.textLabel.text= [deDict objectForKey:@"Name"];
return cell;
}
然而,我沒有得到任何錯誤,因爲當我嘗試刷卡上模擬器,它根本不工作..
他們不是'UITableView'方法,你不會覆蓋它們。他們是委託方法。 – Sulthan
嗯,我現在正在做commitEdittingStyle和titleForDeleteConfirmationButtonForRowAtIndexPath,看到的作品 – user3079947
那麼沒關係,不需要擔心它只是從右向左滑動,你會看到刪除按鈕,它按照commitEdittingStyle按下時執行操作 –