Я реализую в контроллере, тестирование моего устройства - iPhone6S iOS 13.3.1, версия XCode - 11.3.1, мой проект - в Swift 5. Когда я пролистываю влево или вправо, иногда пролистывание просмотра происходит за ячейкой, а ячейка не двигаться, пользовательская ячейка табличного представления является нормальной ... представление в центре с ограничением на суперпредставление для имитируемого расстояния в ячейках и willBeginEditingRowAt я изменяю размер и y положение nativeview свайпа, чтобы иметь равный размер по высоте с имитированной ячейкой расстояния.
override func viewDidLoad() {
super.viewDidLoad()
self.configtable()
}
private func configtable(){
let tbl = UITableView.init()
self.view.addSubview(tbl)
tbl.register(UINib.init(nibName: "TempcellTableViewCell", bundle: nil), forCellReuseIdentifier: "TempcellTableViewCell")
tbl.translatesAutoresizingMaskIntoConstraints = false
tbl.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 10).isActive = true
tbl.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: -10).isActive = true
tbl.topAnchor.constraint(equalToSystemSpacingBelow: self.view.topAnchor, multiplier: 10).isActive = true
tbl.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: -10).isActive = true
tbl.delegate = self
tbl.dataSource = self
tbl.backgroundColor = UIColor.gray
self.filltable()
tbl.reloadData()
}
func filltable(){
self.arraypersonas = [persona]()
self.arraypersonas.append(persona.init(ci: 1, nombre: "Person 1"))
self.arraypersonas.append(persona.init(ci: 2, nombre: "Person 2"))
self.arraypersonas.append(persona.init(ci: 3, nombre: "Person 3"))
self.arraypersonas.append(persona.init(ci: 4, nombre: "Person 4"))
self.arraypersonas.append(persona.init(ci: 5, nombre: "Person 5"))
self.arraypersonas.append(persona.init(ci: 6, nombre: "Person 6"))
self.arraypersonas.append(persona.init(ci: 7, nombre: "Person 7"))
}
и функции делегата просмотра таблицы:
extension TCViewController: UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print(#function)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.arraypersonas.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 110
}
func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath) {
if let cell = tableView.cellForRow(at: indexPath) as? TempcellTableViewCell{
if let spvcell = cell.superview{
for svswipe in spvcell.subviews{
let typeview = type(of: svswipe.self)
if typeview.description() == "UISwipeActionPullView"{
svswipe.frame.size.height = 100
svswipe.frame.origin.y = 5
}
}
}
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TempcellTableViewCell", for: indexPath) as! TempcellTableViewCell
let item = self.arraypersonas[indexPath.row]
cell.lbltitle.text = "\(item.ci) - \(item.nombre)"
cell.containerbg.backgroundColor = UIColor.white
return cell
}
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let Cancel = UIContextualAction.init(style: .normal, title: "Cancel") { (action, view, nil) in
print("Cancel")
}
Cancel.backgroundColor = UIColor.red
let config = UISwipeActionsConfiguration.init(actions: [Cancel])
config.performsFirstActionWithFullSwipe = false // Prevent swiping
return config
}
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let Checkin = UIContextualAction.init(style: .normal, title: "Check-in") { (action, view, nil) in
print("Checkin")
}
Checkin.backgroundColor = UIColor.blue
//Checkin.image = UIImage.init(named: Constants.images.iconcheckinhouse)
let Noshow = UIContextualAction.init(style: .normal, title: "No Show") { (action, view, nil) in
print("No show")
}
Noshow.backgroundColor = UIColor.yellow
//Noshow.image = UIImage.init(named: Constants.images.iconthumbsdown)
//arrayactions.append(Cancel)
let config = UISwipeActionsConfiguration.init(actions: [Noshow,Checkin])
config.performsFirstActionWithFullSwipe = false // Prevent swiping
return config
}
В Mi Custom TableViewCell есть:
class TempcellTableViewCell: UITableViewCell {
@IBOutlet var containerbg: UIView!
@IBOutlet var lbltitle: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
Изображения Свойства Xcode Ограничение подпредставлений TableviewCell
Изображения ошибок: