【发布时间】:2013-12-10 09:22:04
【问题描述】:
我有一个表格视图和一个单元格: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;
}
但是,我没有收到任何错误,因为当我尝试在模拟器上滑动时,它根本不起作用..
【问题讨论】:
标签: objective-c uitableview swipe delete-row