gpt4 book ai didi

ios - 快速更新 tableView 中的标题

转载 作者:行者123 更新时间:2023-11-29 02:09:02 25 4
gpt4 key购买 nike

当我添加新行而不重新加载整个部分时,我正在尝试更新我在部分标题中创建的 label.text。

目前我找到了一个解决方案,但它需要很多 if 语句。我发现一个部分的标题实际上也是一行,行数取决于 iPhone 的 cpu 架构,如果它是 32 行号是 2147483647 如果它是 64 位行号是 9223372036854775807。

我用 iPhone 5

self.tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow:2147483647, inSection:1)], withRowAnimation: .Fade)

其中 2147483647 是标题的行号,....很酷,对吧?

现在我知道这不是一个好方法,我必须对手机版本进行检查。有没有其他方法可以做到这一点,或者我这样做的方式可以吗?

最佳答案

创建UILabel对象

 var lbl_header = UILabel()


func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
{

self.lbl_header.frame = CGRectMake(0, 0, 320, 15)
self.lbl_header.text = "Test"
self.lbl_header.backgroundColor = UIColor.redColor()
return self.lbl_header;

}

现在你想更改 UILabel 的文本 对于前。我点击按钮更改标签的文本

  @IBAction func update_lbl_click(sender: UIButton)
{
self.lbl_header.text = "Hello"
}

它会将 lbl_header 的文本更改为 Hello...

关于ios - 快速更新 tableView 中的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29483956/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com