我有一个UITableViewCell
内的标签计时器,使用此代码如何更新里面的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个单元,但心不是权利,如果大于1多细胞的标记仅只有拉斯细胞更新。 – Piyo 2012-08-07 08:46:00
如果每个小区包含不同的小时,分钟,秒的值则应使用阵列将包含值针对每个小区和在的cellForRowAtIndexPath您应该从阵列[hourArr objectAtIndex:indexPath.row]提供值等on..where hourArr是一个数组明白了吗?在提问时你应该清楚。 – 2012-08-08 04:55:21
谢谢!我知道了。现在它完美的工作! – Piyo 2012-08-08 05:34:16