【发布时间】:2017-09-18 20:39:03
【问题描述】:
我正在使用 swift 3 并有一个 TableView,当用户位于最后一行时,我是否试图触发一段特定的代码。出于某种原因,它完全忽略了这一点并且没有启动。我什至在那里放了一个断点,但它没有击中它。这就是我所拥有的
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == self.Locations.count {
print("Last Row")
}
}
打印语句没有显示断点。我的 TableView 代码是这样的
class HomePageC: UIViewController,UITableViewDataSource {
@IBOutlet weak var TableSource: UITableView!
var Locations = [String]()
override func viewDidLoad() {
super.viewDidLoad()
TableSource.allowsSelection = false
TableSource.dataSource = self
TableSource.estimatedRowHeight = 504
TableSource.showsVerticalScrollIndicator = false
TableSource.rowHeight = UITableViewAutomaticDimension
TableSource.tableFooterView = UIView()
}
func tableView(_ tableView:UITableView, numberOfRowsInSection section:Int) -> Int {
// This always returns 10 items
return Locations.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) ->
UITableViewCell {
// This just populates the fields as I have a custom TableView
}
【问题讨论】:
标签: ios swift uitableview swift3 uiscrollview