我有一个用来覆盖UITextField子类的inputView的UITableViewController。有时,tableView didSelectRowAtIndexPath会停止触发,直到用户收集该表并尝试再次单击。我似乎不能确定是什么导致细胞变得无反应。大多数情况下,它工作得很好,但随机的是,单元格停止对触摸的响应,直到用户滚动了一下表格视图。
据我所知,我在视图中没有任何TapGestureRecognizers,并且尝试过在UITableViewCell中覆盖HitTest,但似乎无法解决这个问题。
对如何更好地调试它有什么想法吗?
下面是tableView控制器代码:
protocol MultiSelectPickerDelegate
{
func didSelectOption(optionIndex:Int, group:Int)
}
class MultiSelectPicker: UITableViewController {
var multiSelectGroups = [MultiSelectGroup](){
didSet{
self.tableView.reloadData()
}
}
var delegate:MultiSelectPickerDelegate?
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return multiSelectGroups.count
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return multiSelectGroups[section].multiSelectOptions.count
}
//MARK: UITableView datasourse function
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
delegate?.didSelectOption(indexPath.row, group: indexPath.section)
}
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRectMake(0, 0, tableView.frame.size.width, 40))
let label = UILabel(frame: CGRectMake(10, 0, tableView.frame.size.width, 40))
label.font = UIFont.systemFontOfSize(14)
label.text = multiSelectGroups[section].name
label.textColor = UIColor.whiteColor()
view.addSubview(label)
view.backgroundColor = UIColor.MyAppBlue()
return view
}
override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 40
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier")
if cell == nil{
cell = UITableViewCell(style: .Default, reuseIdentifier: "reuseIdentifier")
}
cell?.textLabel?.text = multiSelectGroups[indexPath.section].multiSelectOptions[indexPath.row].name
return cell!
}
}发布于 2015-12-18 14:42:33
我也有同样的问题。在我的表格视图中,第一次点击时并没有点击表格的最后一行。它高亮显示了它,但是didSelectRowAtIndexPath没有被调用。所有其他行都工作正常。但是,如果我打开tableview弹跳,那么问题似乎就解决了

同时尝试删除界面生成器中的Show Selection on Touch,如下所示:

希望能有所帮助
https://stackoverflow.com/questions/34342175
复制相似问题