swift - tableView 中的单元格在按下时没有反应

标签 swift uitableview

我的桌面 View 在按下时没有反应。

当我添加时:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
   print("section: \(indexPath.section)")
   print("row: \(indexPath.row)")
}    

它首先在首次加载时打印表格 View 中的所有行和部分,然后再按任何内容。但是在我删除该代码并再次添加它之后,它根本不打印任何内容,即使当我按下单元格时也不打印任何内容。
有人遇到过这种情况吗?

最佳答案

如果你的编译器没有显示,也许你只是之前缺少覆盖。

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    print("section: \(indexPath.section)")
    print("row: \(indexPath.row)")
}  

关于swift - tableView 中的单元格在按下时没有反应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48298129/

相关文章:

ios - 重新加载单元格后向上滚动时具有动态单元格高度的 UITableView 跳跃

ios - popoverPresentationController sourceView inside didSelectRowAtIndexPath on iPad in Swift

ios - Realm 数组索引超出范围

ios - 增加/减少一个值并在 TableViewCell Swift Xcode 中的标签中显示结果

ios - (Swift) 将按钮移动到有异常(exception)的随机位置

iphone - 从 UITableViewCell 刷新 UITableView

ios - swift 4 : New Viewcontroller when tapped on a cell with separate class

swift - 如何在 ForEach SwiftUI 中使用核心数据关系

ios - UITabBar 中的 UIView 未扩展至完整

ios - 自定义tableviewCell内容宽度与tableView不同