我寫,讓每一個細胞在我的TableView一個數量從8日起代碼,當它達到12,我把它叫做在app小時計數器在提供大量的每個細胞中的UITableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
while (hour < 15)
{
if (hour == 12) {
hour=1;
} else {
NSString *str = [NSString stringWithFormat:@"%d",hour];
cell.textLabel.text = [courses objectAtIndex:indexPath.row];
cell.detailTextLabel.text = str;
NSLog(@"%@",str);
hour++;
return cell;
}
}
return cell;}
這工作當我用模擬器運行應用程序時很好,但是當我滾動時,它會不斷更改第一個和第二個單元格中的數字,即使滾動表格,我也希望數字不會改變。
我該怎麼做? 在此先感謝。
哦卡,請不要介意我所說的xD – Cashew 2013-03-27 04:11:47
這就是我得到不讀正確的代碼 – Cashew 2013-03-27 04:12:10
添加以下代碼後的UITableViewCell *電池=的tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; /// 如果(細胞== nil){= [[[UITableViewCell alloc] initWithFrame:CGRectZero \t \t reuseIdentifier:MyIdentifier] autorelease]; } – NANNAV 2013-03-27 04:23:10