我浏览了很多网站,但仍然没有答案。
我有一个方法假设void xyz()
,它会被 View Controller 自动调用 每 3 秒之后。
我不知道该用什么,我必须使用 NSThread 还是 PerformSelector。
最佳答案
从 ViewDidLoad 方法调用此方法。ViewDidLoad 将在您的 View 出现在 iPhone 设备或模拟器中时执行。
[NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(runMethod) userInfo:nil repeats:YES];
-(void)runMethod
{
}
关于ios - 在后台 3 秒时间间隔后重复调用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22193131/