0

Something strange is happening for me with reloadData ONLY IN iOS 7.1. This code works PERFECTLY in iOS 7.0. I update some variables and then call reloadData:

myNum = 12;
[self.tableView reloadData];

then in cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    … 
    [cell.leftScoreButton setTitle:[NSString stringWithFormat:@"%d", myNum] forState:UIControlStateNormal];
    cell.leftScoreButton.enabled = NO;
    … 

This is no longer updating the button title correctly in 7.1, but it works fine in 7.0. Also if I pop up with an AlertDialog, then it will successfully reload the tableView button with the correct title. What part of AlertDialog calls update/refresh the underlying screen? Can I call that manually without actually popping up with an AlertDialog?

I have already tried calling [self.view setNeedsDisplay] and setNeedsLayout. Neither helped.

Adam Johns
  • 35,397
  • 25
  • 123
  • 176
  • I've also noticed several iOS 7.1 only UI bugs, it seems like it's more of a step backwards than forwards. – klcjr89 Mar 16 '14 at 23:33

3 Answers3

3

After playing around for a while I noticed it is related to the buttons being enabled. For the row that wasn't updating properly I had the buttons disabled. I just added

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    … 
    [cell.leftScoreButton setTitle:[NSString stringWithFormat:@"%d", myNum] forState:UIControlStateNormal];
    cell.leftScoreButton.enabled = YES;
    cell.leftScoreButton.enabled = NO;
    … 

so I enable and then immediately disable, and now they update properly.

Adam Johns
  • 35,397
  • 25
  • 123
  • 176
0

I had the same issue.

Resolve by setting same title for UIControlStateNormal, UIControlStateSelected and UIControlStateHighlighted.

Looks more clean solution.

megimix
  • 78
  • 1
  • 7
0

In my case this code did the work for me:

[cell.buttonName setNeedsLayout];

I asked the button to be layout again.

cessmestreet
  • 2,298
  • 3
  • 22
  • 42