NSTimer卡住了

时间:2015-05-27 23:48:19

标签: ios objective-c nstimer

我有一个使用NSTimer更新UI的应用程序,同时,应用程序有很多日志消息正在使用另一个线程,我遇到的问题是当应用程序正在登录时,Timer未被触发,直到所有日志消息都完成。 代码:

NSTimer* timer = [NSTimer timerWithTimeInterval:0.1 target:self selector:@selector(change:) userInfo:imageView repeats:YES];

[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];

[MessageProcessor StartLogging];

更改功能:

- (void)change:(id)sender
{
    p += 0.1;
    UIImageView* view = (UIImageView*)[sender userInfo];
if (p>2) {
    p = 0;
}

// here rotate the image

}

StartLogging完成后,定时器将调用更改函数,我想知道原因,以及如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我想我找到了这个案例,是的,你们是对的,在StartLogging方法中,我调用主线程处理一些数据并让它等待处理数据的单位。 谢谢你们。

相关问题