我想顯示顯示在tableview中的每個單元號的標籤,但是當我點擊一個行(當電池被反白標明)uitableview子視圖:爲什麼這個uilabel不可見?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UILabel *label;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
label = [[UILabel alloc] initWithFrame:CGRectMake(200,10, 15, 15)];
label.tag = 1;
[cell.contentView addSubview:label];
[label release];
}
else {
label = (UILabel *)[cell viewWithTag:1];
}
if (indexPath.row == 0) {
cell.textLabel.text = @"Photos";
label.text = [NSString stringWithFormat:@"%d",1];
}
return cell;
}
你知道如何確保該爲textLabel觀點並沒有放置在內容查看子視圖的頂部? 原因實際上是我遇到的問題,文本標籤隱藏標籤 – Mathieu 2009-09-16 04:32:02
您可以使用「-tableView:willDisplayCell:forRowAtIndexPath:」在顯示之前重新排列單元格的視圖。 – 2009-09-16 04:47:22