msk*_*msk 5 iphone uitableview
我可以通过调用[tableView setEditing:YES]来设置uitableview的编辑模式; 但是,它为表中的所有行设置编辑模式.
有没有办法检测哪个行被刷过,只为该行启用编辑模式?
谢谢
我没有对此进行编码,但这是一个想法.
在.h中创建selectionIndexPath
NSIndexPath *selectionIndexPath;
Run Code Online (Sandbox Code Playgroud)
然后在.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
将indexPath保存到selectionIndexPath并调用:
[self.tableView setEditing:YES];
Run Code Online (Sandbox Code Playgroud)
然后在:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
if (selectionPath.row == indexPath.row)
{
return UITableViewCellEditingStyleDelete;
}
else
{
return UITableViewCellEditingStyleNone;
}
}
Run Code Online (Sandbox Code Playgroud)
你也可以抓住接触,然后或多或少做同样的事情.像这样......
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
if (indexPath != nil)
{
// save indexPath and setEditing Mode here
}
Run Code Online (Sandbox Code Playgroud)
没有时间对其进行编码,但这是主要的想法.
| 归档时间: |
|
| 查看次数: |
12059 次 |
| 最近记录: |