objective-c - 按下 UIButton 后 UILabel 显示 3 秒

标签 objective-c cocoa-touch uilabel nstimer

按下暂停按钮后,我希望出现一个标签,直到用户点击屏幕。我该怎么做?

到目前为止我已经有了这个

- (IBAction)ButtonPausePressed:(id)sender {

 PauseLabel.hidden = false (//how do i make it only visible until user taps?//)

if (GameEnd != true){
    if ([GameUpdate isValid]){
        [GameUpdate invalidate];
        [BirdUpdate invalidate];
    }else{
        BirdUpdate = [NSTimer scheduledTimerWithTimeInterval:0.015
                                                      target:self
                                                    selector:@selector(UpdateBird)
                                                    userInfo:nil
                                                     repeats:YES];
        GameUpdate = [NSTimer scheduledTimerWithTimeInterval:0.025
                                                      target:self
                                                    selector:@selector(GameUpdate)
                                                    userInfo:nil
                                                     repeats:YES];
    }
}
}

最佳答案

- (IBAction)ButtonPausePressed:(id)sender { 
   PauseLabel.hidden = false
   [self performSelector:@selector(hiddenLabel) withObject:nil afterDelay:3];
   ...
}

- (void)hiddenLabel{
    PauseLabel.hidden = YES;
}

关于objective-c - 按下 UIButton 后 UILabel 显示 3 秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22598428/

相关文章:

ios - 如何将 UILabel 连接到其他类

iphone - Objective C - 为我的 iPhone 应用程序创建一个框架?

objective-c - UIView 中的签名

iOS POST 到 Rails - 参数不包含 :modelname 的值

ios - 如果 UIStepper 在 Swift 4 中以编程方式点击,如果它们都在 UITableViewCell 中,如何更改 UILabel 的文本?

ios - Swift 4 - 如何从 socket 集合中的自定义 UIView 获取 UI 元素?

iphone - iOS - 从应用程序获取 CPU 使用率

ios - ILTableViewCell/UITableViewCell 生命周期

ios - SIGABRT 因 SDWebImageCache 而崩溃

iphone - 如何制作带列的 UITable?