UITableViewCell
このコードを使用して、の中にラベルタイマーがあります
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [[UITableViewCell alloc]init];
timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(55, 26, 280, 25)];
timeLabel.text = [timeArray objectAtIndex:indexPath.row];
timeLabel.backgroundColor = [UIColor clearColor];
timeLabel.textColor = [UIColor blackColor];
[cell.contentView addSubview:timeLabel];
return cell;
NSLog(@"Title %@, time %@, second %@, time %i, tag %d", titleArray, timeArray, secondArray, time, button.tag);
}
そして、私はこのコードを使用してボタンでトリガーするタイマーを持っています
- (void)onoffBtn:(id)sender
{
countdownTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerElapsed:) userInfo:nil repeats:YES];
}
- (void) timerElapsed:(id)timer
{
if (time == 0)
{
[countdownTimer invalidate];
}
// this part only code for counting down timer
NSLog(@"%d:%d:%d", hour , minute, second);
}
中に入れtimeLabel.text = [NSString stringWithFormat:@"%d:%d:%d", hour , minute, second];
てtimerElapsed
も、もちろんセル内のラベルは更新されません。
では、セル内のラベルを1秒ごとに更新するにはどうすればよいですか?