gpt4 book ai didi

iphone - 刷新uitableview数据

转载 作者:行者123 更新时间:2023-12-03 20:29:20 25 4
gpt4 key购买 nike

如何每5分钟刷新一次UITableView的内容?

最佳答案

结账 NSTimer和 UITableViews reloadData。

假设当前 Controller 的 View 是 UITableView,并且您已在 Controller 中声明了一个名为计时器的 NSTimer,则以下代码应该可以解决问题:

- (void)viewDidLoad {
timer = [NSTimer scheduledTimerWithTimeInterval:300.0
target:[self view]
selector:@selector(reloadData)
userInfo:nil
repeats:YES];

[super viewDidLoad];
}

更新:

其他人建议使用 timerWithTimeInterval:target:selector:userInfo:repeats: ,它与我在示例中使用的 scheduledTimerWithTimeInterval 基本相同。

不过,它们的不同之处在于,scheduledTimerWithTimeInterval 将计时器添加到当前运行循环,而使用timerWithTimerInterval 方法,您需要将计时器添加到您自己的运行循环。

关于iphone - 刷新uitableview数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3249016/

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