Hey guys,
in my view controller there is a WKInterfaceTable and a WKInterfaceLabel underneath it. Usually the label is hidden, but if there isn't any data to fill the table the label shall show up. The following code snippet shows the obvious approach:
- (void)populateData {
// ...
NSInteger numberOfEvents = [self removeUnwantedObjectsFromArray].count;
[self.tableView setNumberOfRows:numberOfEvents withRowType:@"Heute"];
if (numberOfEvents == 0) {
[self.noDataLabel setHidden:NO];
} else {
[self.noDataLabel setHidden:YES];
// ...
}
}
When the else block is executed for the first time, the cell spacing in the WKInterfaceTable is normal; but when the if condition returns true and setHidden: is set NO the cell spacing will be increased the next time the else block is executed. This surprises me because according to the documentation a hidden object is effectively removed from your interface. "During layout, hidden items are treated as if they were removed entirely from the layout altogether. When you hide or show an object in your interface, WatchKit makes a note to update the layout during the next refresh cycle. During that cycle, WatchKit adjusts the layout to display only the currently visible objects." If I got the documentation correctly, hidden items don't occupy any space at all. Does anyone of you have a clue why setHidden: increases the cell spacing, though? I really appreciate any help you can provide. Thank you so much for your help!!! 🙂
Kind regards,
Alex