如何设置 NSTimer 在将来触发一次(例如 30 秒)。到目前为止,我只能将其设置为立即触发,然后每隔一段时间触发。
您要使用的方法是:
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval) seconds target:(id) target selector:(SEL) aSelector userInfo:(id) userInfo repeats:(BOOL) repeats
with repeats == NO
论据和seconds == 30
。这将创建计时器并安排它。它只会在 30 秒内触发一次(而不是立即触发)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)