如何将 NSTimer 设置为在将来触发一次(比如 30 秒)。到目前为止,我只是设法将其设置为立即触发,然后每隔一段时间触发一次。
最佳答案
您要使用的方法是:
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval) seconds target:(id) target selector:(SEL) aSelector userInfo:(id) userInfo repeats:(BOOL) repeats
使用 repeats == NO
参数和 seconds == 30
。这将创建计时器并安排它。它只会在 30 秒内触发一次(不会立即触发)。
关于iphone - 将 NSTimer 设置为在将来触发一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7765044/