私はswift 3を使用しており、TableViewを持っています。ユーザーが最後の行にいるときに特定のコードを起動しようとしていますか?なんらかの理由で、それは完全に無視され、発射されません。私はそこにブレークポイントを置いていても、それは当たらない。これは私が持っているものですIOS TableViewが最後の行コードに応答しない
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == self.Locations.count {
print("Last Row")
}
}
printステートメントにブレークポイントも表示されていません。私のテーブルビューのコードは、あなたがself.Locations.count - 1
に対する等価性をチェックする必要があり、この
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
}
ありがとうございました。 –