ios - 选中单元格后如何移动

标签 ios swift uitableview cells

我正在锁定方法中的解决方案

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: UIIndexPath) {
}

在我选择一行后它应该改变颜色并移动到数组的末尾,另一个应该向上移动

最佳答案

要向下移动行,您可以这样做:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: UIIndexPath) {
    //move selected cell down to last row
    tableView.moveRowAtIndexPath(indexPath, toIndexPath:NSIndexPath(forRow: tableView.numberOfRowsInSection(indexPath.section)-1, inSection: indexPath.section))
}

要更改颜色,请参阅 How to change color of UITableViewCell when selecting?

关于ios - 选中单元格后如何移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35010074/

相关文章:

ios - 水平翻转视频如果这样则没有镜像效果

ios - 在 Swift 中为 NSMutableAttributedString 设置 kCTUnderlineStyleAttributeName

ios - UITableViewController 在模拟器中显示白色空白屏幕

ios - 如何阻止包含强标签的自定义单元格覆盖内容?

iphone - 当用户向下滚动 UITableView,经过最后一个单元格时,为什么我的应用程序退出?

ios - 我们如何删除线条

iphone - iPhone 应用程序的开发版本何时到期?

ios - 在项目选择上调用委托(delegate)方法

swift - 为什么指向new Object后内存地址是一样的?

ios - 如何在 iOS 中给卡片一样的阴影