I'm creating a universal iPhone/iPad app and I want to have custom cells on the main view. It's working fine for iPhone, but on iPad dequeueReusableCellWithIdentifier: returns nil instead of cells. Here's some of my code (I replaced my custom cells with normal UITableViewCell since it doesn't work anyway):
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
CellIdentifier = @"MainPadCell"; //works fine when replaced with MainPhoneCell
__weak UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; //returns nil
[cell.textLabel setText:@"Test"];
return cell; //crash
}else{
CellIdentifier = @"MainPhoneCell";
__weak UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
[cell.textLabel setText:[NSString stringWithFormat:@"Cell %i", indexPath.row]];
return cell;
}
}
Weird thing is, that when I replace MainPadCell cell with MainPhoneCell it shows the phone cells (though I don't have any MainPhoneCell reuse identifier in my iPad Storyboard, I have MainPadCell in iPad storyboard and it can't find it).
Thanks for any advice!