我每次出現該視圖時都會創建自定義單元格並更新一些UILabel
。UILabel值在cellForRowAtIndexPath中不更新?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UILabel *lblFacingValue = nil;
static NSUInteger const kFacingLabelTag = 7;
CGFloat LeftLabelWidth = 130.0;
static NSString *CellIdentifier = @"Cell";
ClientState *clientState = [ClientState sharedInstance];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if(indexPath.row == 0)
{
lblFacingValue = [[[UILabel alloc] initWithFrame:CGRectMake(246, -11, LeftLabelWidth, (cell.contentView.frame.size.height))] autorelease];
lblFacingValue.font = [UIFont systemFontOfSize:21];
lblFacingValue.textAlignment = UITextAlignmentLeft;
lblFacingValue.backgroundColor = [UIColor clearColor];
lblFacingValue.tag = kFacingLabelTag;
lblFacingValue.textColor = [UIColor yellowColor];
[cell.contentView addSubview:lblFacingValue];
}
}
lblFacingValue.text = [NSString stringWithFormat:@"%@", clientState.Direction];
}
但問題是它包含我第一次分配的值,並且在打開該視圖時不更新它。該視圖在標籤中。
它沒有更新lblFacingValue的價值,並跳過檢查
如果(細胞==零)
第一時間之後。但不要更新lblFacingValue。
你是什麼意思,它包含我第一次分配的值,當我打開該視圖時不更新它。你如何更新細胞?編輯:好吧,明白了。 – akashivskyy
你的意思是你有兩個標籤 - 其中一個應該更新,另一個不應該? – akashivskyy