问题描述
我想继续用滑动手势降低表格视图的排列,如图所示。 使用长按移动到底部单元格,但只关注焦点。 轻微移动即可让您回到原来的位置。
我们如何解决这个问题?
请礼貌地帮助我。
我的代码。
let dataArray = [Int](0...50);
// long press
let longPressGesture = UILongPressGestureRecognizer(target: self,action: #selector(handleLongPress))
longPressGesture.minimumPressDuration = 0.5
self.tableView.addGestureRecognizer(longPressGesture)
}
// swipe gesture
@objc private func respondToSwipeGesture(gesture: UIGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizer.Direction.down:
print("======= Swiped down")
case UISwipeGestureRecognizer.Direction.up:
print("======= Swiped up")
default:
break
}
}
}
// long press
if tableView.contentSize.height > tableView.frame.size.height {
let offset = CGPoint(x: 0,y: tableView.contentSize.height - tableView.frame.size.height)
tableView.setContentOffset(offset,animated: true)
}
}
}
// table view
func tableView(_ tableView: UITableView,numberOfRowsInSection section: Int) -> Int {
return self.dataArray.count
}
func tableView(_ tableView: UITableView,cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .subtitle,reuseIdentifier: nil)
cell.textLabel?.text = "\(self.dataArray[indexPath.row])"
//cell.detailTextLabel?.text = "\(indexPath.row + 1)"
return cell
}
func tableView(tableView: UITableView,cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell:UITableViewCell=UITableViewCell(style: .subtitle,reuseIdentifier: nil)
cell.textLabel?.text="row#\(indexPath.row)"
// cell.detailTextLabel?.text="subtitle#\(indexPath.row)"
return cell
}
结束
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)