我正在使用自定义tableViewCell
我要在iOS中制作类似Mail应用的tableViewCell
当用户向左或向右滑动单元格时,
它显示按钮和翻译
它与默认值不同,如下所示。
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete{
self.allChatroomList.remove(at:indexPath.row)
self.tableView.reloadData()
}
}
所以我正在与UISwipeGesture合作,但我无法获得翻译或职位 我怎么能得到它?
rightDelete.frame = CGRect(x:UIScreen.main.bounds.width, y:0, width:50, height:71)
rightHide.backgroundColor = UIColor.red
addSubview(rightHide)
let leftSwipe = UIPanGestureRecognizer(target: self, action:#selector(self.swipe))
leftSwipe.delegate = self
mainView.isUserInteractionEnabled = true
self.mainView.addGestureRecognizer(leftSwipe)
func swipe(gesture: UIPanGestureRecognizer){
let translation = gesture.translationInView(self.view)
let swipeGesture:UISwipeGestureRecognizer = gesture as! UIpanGestureRecognizer
if(swipeGesture.direction == .left)
{
self.leftHide.centerX = self.leftHide.centerX + translation.x
self.leftDelete.centerX = self.leftDelete.centerX + translation.x/2
}
else if(swipeGesture.direction == .right)
{
}
}
}