Reputation: 679
I have a very strange problem and I've got a feeling it's going to be a weird solution like I have the wrong provisioning profile (checked that!).
I can run on the Simulator and one of my iPhone 5's and I have a UITableView populating with some cells, all playing nice.
However, I've just run it on my 5S and the table view is completely blank. The cells aren't selectable or anything. I've checked the TableView isn't getting released or anything, and it is responsive if I pull down to refresh. I can even see my logging saying the numberOfRows... and cellForRow.. methods are getting called again if I pull to refresh, just no UI is displayed at all!
Here's various snippets in case this helps:
- (void)viewDidLoad
{
...
UINib *cellNib = [UINib nibWithNibName:@"EJCMatchInboxCell" bundle:nil];
[self.matchTable registerNib:cellNib forCellReuseIdentifier:kEJCMatchInboxCellIdent];
UINib *segmentedCellNib = [UINib nibWithNibName:@"EJCSegmentedControlCell" bundle:nil];
[self.matchTable registerNib:segmentedCellNib forCellReuseIdentifier:kEJCMatchInboxSegmentedControlCellIdent];
...
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(refresh)
forControlEvents:UIControlEventValueChanged];
[self.matchTable addSubview:self.refreshControl];
...
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row == 0 && indexPath.section == 0) {
return NO;
}
return YES;
}
- (long)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (long)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
long rowCount = matches.count + 1;
NSLog(@"MatchInboxVC::numberOfRowsInSection %li", rowCount);
return rowCount;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"MatchInboxVC::cellForRowAtIndexPath %li", indexPath.row);
if(indexPath.row == 0 && indexPath.section == 0) {
// segmented control cell
EJCSegmentedControlCell *cell = [tableView dequeueReusableCellWithIdentifier:kEJCMatchInboxSegmentedControlCellIdent];
// Configure the cell...
if (cell == nil) {
cell = [[EJCSegmentedControlCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kEJCMatchInboxSegmentedControlCellIdent];
}
[cell.segmentedControl setSelectedSegmentIndex:selectedSegmentIndex];
[cell.segmentedControl addTarget:self action:@selector(changedSegmentSelection:) forControlEvents:UIControlEventValueChanged];
[cell.segmentedControl setTitle:@"Current" forSegmentAtIndex:0];
[cell.segmentedControl setTitle:@"Deleted" forSegmentAtIndex:1];
return cell;
}
else {
// match cell
EJCMatchInboxCell *cell = [tableView dequeueReusableCellWithIdentifier:kEJCMatchInboxCellIdent];
// Configure the cell...
if (cell == nil) {
cell = [[EJCMatchInboxCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kEJCMatchInboxCellIdent];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
EJCMatch *m = matches[indexPath.row - 1];
[cell setupWithMatch:m];
return cell;
}
}
- (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row == 0 && indexPath.section == 0) {
return 38.0f;
}
else {
return 65.0f;
}
}
Logging output:
MatchInboxVC::numberOfRowsInSection 2
MatchInboxVC::cellForRowAtIndexPath 0
MatchInboxVC::cellForRowAtIndexPath 1
Upvotes: 0
Views: 877
Reputation: 679
Right - I guess this was my own fault for forgetting to read the method definition properly, but apparently setting a return type of (float) for heightForRowAtIndexPath on the 5S will prevent the cells displaying at all.
Solved by changing the method definition from
- (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
to
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Upvotes: 2