Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewStyleGrouped appears as plain in iOS 6

When using the iOS 6 SDK and running my app in the iPhone 5.0 simulator my tableview appears just fine as a grouped style tableview. However when I run my in the iPhone 6.0 simulator it appears as a UITableViewStylePlain tableview.

Any ideas what would cause this strange behavior? I'm not doing anything too crazy in the tableview besides a textview inside a tableview cell.

like image 931
Steve Moser Avatar asked Sep 21 '12 14:09

Steve Moser


2 Answers

I have a grouped tableview that is working correctly in iOS6 using the code:

tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.bounds.size.width,self.bounds.size.height) style:UITableViewStyleGrouped];
[tableView setDataSource:self];
[tableView setDelegate:self];

Are you using the Interface builder to create this grouped tableview or are you creating it programmatically? There seems to be quite a few issues with iOS6 and previously created interfacebuilder views.

If you are using the IB to create things can you try to re-create the tableview in code (redundant and useless, I know, but it may show what is the problem).

Somewhere in your viewDidLoad() function put

    if(tableView)
    {
        [tableView removeFromSuperview];
    }
    tableView = [[UITableView alloc] initWithFrame:tableView.frame style:UITableViewStyleGrouped];
    [tableView setDataSource:self];
    [tableView setDelegate:self];
    [self addSubview:tableView];

This may be poor coding or cause memory leaks if not using arc, but it would be interesting to see if you get a grouped styling that way.

like image 116
Putz1103 Avatar answered Nov 15 '22 09:11

Putz1103


This code solved the ios6 grouped tableview problem for me:

tableView.backgroundColor = [UIColor clearColor];
tableView.opaque = NO;
tableView.backgroundView = nil;
like image 31
user1689394 Avatar answered Nov 15 '22 09:11

user1689394