【发布时间】:2017-05-11 00:59:05
【问题描述】:
我想在 UITableView 的函数 onReload 上运行一些代码。基本上现在我只想打印数组中有多少项。稍后我会根据项目的数量来显示或不显示视图。
所以我希望在 UITableView 刷新或重新加载或类似情况时运行此代码。
我怎样才能做到这一点?
【问题讨论】:
标签: ios swift uitableview
我想在 UITableView 的函数 onReload 上运行一些代码。基本上现在我只想打印数组中有多少项。稍后我会根据项目的数量来显示或不显示视图。
所以我希望在 UITableView 刷新或重新加载或类似情况时运行此代码。
我怎样才能做到这一点?
【问题讨论】:
标签: ios swift uitableview
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
//dataArray is your data array
// > 10 is your condition
if dataArray.count >10{
return 0
}else{
return dataArray.count
}
}
【讨论】:
UITableViewDataSource/Delegate的原理,你会节省很多时间