ios - willDisplay 单元格中的函数也在视图加载时调用
问题描述
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if userType == "2" {
if (indexPath.section == (page * 10) - 2) && (page > 0) && (pagedone == false){
self.setupInbox(self.appDele!.glat, slng: self.appDele!.glong, animate: false)
if (page >= 1 ) {
page = page + 1
}
}
} else if userType == "1" {
if indexPath.section == 10 {
showAlert()
}
}
}
override func numberOfSections(in tableView: UITableView) -> Int {
return arrayOfRels.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
guard let release = arrayOfRels[exist: indexPath.section] else { return 0 }
if release.isAttendingNow == "1" {
return 120.0
}
return 90.0
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 5
}
// Make the background color show through
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerView = UIView()
headerView.backgroundColor = UIColor.clear
return headerView
}
加载视图时也会调用 showAlert() 函数。
仅应在 indexPath.section == 10 时调用
我怎样才能让它工作?
解决方案
如果您的屏幕足够大,可以在之后立即显示第 10 节viewDidLoad
,那么showAlter()
在viewDidLoad
假设您userType
是1
推荐阅读
- google-cloud-trace - 使用 REST api 创建不同的颜色范围
- javascript - 如何在猫鼬聚合中找到平均值
- wordpress - 如何在 WordPress 的 url 中删除自动生成的图像大小
- html - InvalidPipeArgument:在 invalidPipeArgumentError 处管道“AsyncPipe”的“[object Object]”
- c - 如何将double类型的矩阵保存在文件中
- c++ - 为什么我的 scanf() 没有为我的数组上的 for 循环迭代?
- java - 未生成 Itext PDF 文件
- c# - 程序返回“不支持关键字:‘元数据’。”
- python - 通过不同数量的分隔符创建嵌套列表(但相同)
- symfony4 - Symfony 4 左加入存储库