In IOS7 the UITableView does not have indentation anymore when using style=grouped. How can enable the indentation, so that the UITableView behaves like the settings app from apple?
-
Look at this link. It shows how to set up a grouped UITableView http://mobisoftinfotech.com/iphone-uitableview-tutorial-grouped-table/ – erdekhayser Sep 26 '13 at 00:37
-
2No, I know how this works. But in IOS7 they removed the indentation, but I need it. Apple uses them in their settings app too. – Philipp Schaller Sep 26 '13 at 07:42
-
What indentation you mean exactly? The separators or the text? If you put your subviews in contentview of the cell, everything should look fine.. – Bms270 Sep 26 '13 at 17:19
-
Like in IOS6, the grouped tableviewcells had an indention with rounded corners. In IOS7 the bounds of the cells will go to the end of the tableview. – Philipp Schaller Sep 26 '13 at 21:26
-
Here's the thing- Apple wants developers to utilize the entire screen in iOS 7. That's what they did in the Weather app and the Settings app. They specifically do not want you to indent the table view. If you definitely need to do it, then do you need the header, the table, or everything moved off the edge? – erdekhayser Sep 26 '13 at 21:37
-
If I understand correctly you want to create the same look of iOS6 group style in iOS7? IF that's the case then you would need to create your own cells (playing with their background) and remove the separators. I can give you a full explanation to answer your question but wanted to make sure this is what you are looking for. – Bms270 Sep 27 '13 at 13:47
-
1Duplicate of http://stackoverflow.com/questions/18822619/ios-7-tableview-like-in-settings-app-on-ipad – Racura Sep 30 '13 at 01:39
3 Answers
There is a much simpler way to achieve this.
Place your UITableView away from the sides. eg: using Autolayout you'd have a leading and trailing space of 15px (or whatever you want). You're now creating the 'indentation' that Apple used to give you for free with grouped table views.
Adjust the layer to add corners and a border.
[[[self tableView] layer] setCornerRadius:5.0f];
[[[self tableView] layer] setBorderWidth:0.5f];
[[[self tableView] layer] setBorderColor:[[UIColor redColor] CGColor]];
(I can't post an image of the result because I don't yet have enough reputation)

- 269
- 2
- 9
An answer is located here, if you still looking for a solution,
http://i-phone-dev.blogspot.no/2014/04/keep-ios-6-uitableview-styles-in-ios-7.html

- 15,408
- 7
- 58
- 96
Inside cellForRowAtIndexPath
method, try this:
CALayer *sublayer = [CALayer layer];
UIImage *img = [UIImage imageNamed:@"blue_box_6dbcef.png"];
sublayer.backgroundColor = [[UIColor alloc] initWithPatternImage:img].CGColor;
sublayer.frame = CGRectMake(10,0,container.frame.size.width-20, 112);
//sublayer.cornerRadius = 5; // For rounded corners
UIView *bgview = [[UIView alloc] init];
bgview.backgroundColor = [UIColor clearColor];
[bgview.layer addSublayer:sublayer];
cell.backgroundView = bgview;
That will add a 10pt margin on both sides (left/right) of the cell.

- 523
- 1
- 7
- 10