【发布时间】:2015-01-06 15:15:23
【问题描述】:
我一直在尝试为此寻找解决方案,想知道是否有任何方法可以模拟单元格滑动,因此当您点击单元格时,它会滑动以显示其选项(即删除选项)。我实际上正在使用 MSSwipeTable 单元格 (https://github.com/MortimerGoro/MGSwipeTableCell),我喜欢动画效果,但我希望它能够用于点击不滑动的单元格。有什么想法吗?
谢谢
【问题讨论】:
标签: ios uitableview
我一直在尝试为此寻找解决方案,想知道是否有任何方法可以模拟单元格滑动,因此当您点击单元格时,它会滑动以显示其选项(即删除选项)。我实际上正在使用 MSSwipeTable 单元格 (https://github.com/MortimerGoro/MGSwipeTableCell),我喜欢动画效果,但我希望它能够用于点击不滑动的单元格。有什么想法吗?
谢谢
【问题讨论】:
标签: ios uitableview
在 Swift 中,您可以执行以下操作:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let cell = self.tableView.cellForRowAtIndexPath(indexPath) as! MGSwipeTableCell
cell.showSwipe(MGSwipeDirection.RightToLeft, animated: true)
}
【讨论】:
MGSwipeTableCell 中有一个方法:-(void) showSwipe: (MGSwipeDirection) direction animated: (BOOL) animated;
您只需在 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 方法中调用它。
【讨论】: