选择按钮时更新NSTime

时间:2014-04-07 13:40:36

标签: ios button uiviewcontroller uikit nstimer

- (void)viewDidLoad{
    [super viewDidLoad];
    counterLabel.text = [NSString stringWithFormat:@"Your counter is: %d",seconds];
    seconds = 0;
    randomTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0/1.0) target:self selector:@selector(randomMainVoid) userInfo:nil repeats:YES];
}

-(void)randomMainVoid{
    seconds += 1;
    counterLabel.text = [NSString stringWithFormat:@"Your counter is: %d",seconds];
}

-(IBAction)Green:(id)sender{
    seconds+=2;
    colorLabel.textColor = [UIColor greenColor];
    colorLabel.text = @"Your color is: Green";
}

我的第一种方法是更新秒并显示它。我有一个按钮,当我点击它时我希望秒数增加一倍。我该怎么做?

0 个答案:

没有答案