gpt4 book ai didi

objective-c - Objective-C/iPhone : How to add a timer to let the text update?

转载 作者:搜寻专家 更新时间:2023-10-30 19:45:23 24 4
gpt4 key购买 nike

我想编写一个允许用户倒计时的应用程序。时间将使用标签显示。我想每秒更新一次标签,我该怎么做?或者哪个 API 适合我做这个?提前。

最佳答案

- (IBAction)startCountdown:(id)sender
{
NSTimer *countdownTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(advanceTimer:) userInfo:nil repeats:YES];
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
[runLoop addTimer:countdownTimer forMode:NSDefaultRunLoopMode];
}

- (void)advanceTimer:(NSTimer *)timer
{
[countdown setIntegerValue:59];
}

+1up ;)

关于objective-c - Objective-C/iPhone : How to add a timer to let the text update?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2471444/

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