Mam trzy UILabels
w moim niestandardowym UITableViewCell
. może się okazać, że niektóre UILabels
będzie pusta (label.text == @""
)Auto Layout UILabels
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"EventCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSString *key = [[keysArray objectAtIndex:indexPath.section] description];
UILabel *nameLabel = (UILabel *)[cell viewWithTag:100];
namelabel.text = @"Label 1";
UILabel *locationLabel = (UILabel *)[cell viewWithTag:101];
location.text = @"Label 2";
UILabel *timeLabel = (UILabel *)[cell viewWithTag:102];
timeLabel.text = @"";
return cell;
}
Jak mogę wyśrodkować wszystkie niepuste UILabels
pionowo w komórce przy użyciu automatycznego układu?
Jak to wygląda z trzech etykiet
Jak to wygląda, gdy jeden z UILables
jest pusty
I to jest jak chcę to wygląda:
Czy budujesz komórkę w kodzie lub w konstruktorze interfejsu? Dlaczego ma znaczenie, czy etykiety są puste, czy nie? – jrturton
W IB. Chcę, aby moje etykiety były wyśrodkowane w pojemniku. Nie jest to trudne, ale gdy jedna z etykiet jest pusta, dostaję przerwę między dwiema innymi etykietami, które nie wyglądają ładnie. – Oleg
To może być bardzo trudne, ponieważ pusty UILabel może nie zgłasza szerokości, ale z pewnością wysokości, więc być może będziesz musiał napisać kod wzdłuż linii "jednej z etykiet jest pusty, usuń tę etykietę". – 11684