我有一個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