按下UIButton后UILabel持续3秒钟

时间:2014-03-28 23:00:23

标签: ios objective-c uibutton

我现在正在使用它并且我工作了几天而不是突然停止工作所以它现在在那里我按下按钮直到游戏结束.... - (IBAction)ButtonPausePressed:(id)发件人{

if(GameOver.hidden == false)
    return;
PauseLabel.hidden = false;
[PauseLabel performSelector:@selector(setHidden:) withObject:@1 afterDelay:3];

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];
    }
}

}

1 个答案:

答案 0 :(得分:0)

尝试使用GCD,而不是执行选择器。像这样:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
   PauseLabel.hidden = YES;
});