Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subtitles of UITableViewCell won't update

Tags:

ios

xcode6

ios8

Today I started to get my apps ready for iOS8. I discovered that the subtitles of my UITableCells won't update within viewWillAppear. I brought that down to a minimal example:

I've got a static cell TableViewController with 2 cells (style = subtitle) One subtitle is empty the other one is set.

Interface builder screenschot

I update the subtitles like this:

- (void) viewWillAppear:(BOOL)animated {   [super viewWillAppear:animated];   [[self.without detailTextLabel] setText:@"foobar"];   [[self.with detailTextLabel] setText:@"barfoo"]; } 

While everythin works under iOS7 (and 6 and 5), iOS8 won't update the title of the first cell.

screenshot of simulator

However, when I touch the cell it will update and show the text.

Is this a simulator issue? A bug? Am I doing something wrong?

like image 350
lupz Avatar asked Sep 11 '14 16:09

lupz


1 Answers

As a temporary work around I simple introduced a blank space in the text label and programmatically where I set the label text to nil, I set it to a blank space

cell.detailTextLabel.text = @" "; 

Adjust your logic accordingly to deal with a lone blank space as nil.

For me the detail text label didn't show up even though I had a string ready for it before the viewcontroller loaded. one of my many cells shows the current date in a detail text label as default whenever the view controller appears, but that didn't work either.

I think this has something to do with the fact that the iOS 8 is not able to update the text label's text if it set to nil initially.

So see to it that you introduce a blank space in your prototype cell as well, in interface builder. Surprisingly text in labels of my custom cells are working fine.

like image 161
AceN Avatar answered Sep 24 '22 04:09

AceN