przegląd poglądów: dlaczego ten uilabel nie jest widoczny?
Chcę wyświetlić etykietę pokazującą liczbę w każdej komórce widoku tabeli, ale etykieta jest widoczna tylko po kliknięciu wiersza (gdy komórka jest zaznaczona)
- (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;
}