Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GhostDZ9

macrumors regular
Original poster
Sep 13, 2010
118
0
Hey guys,

So im creating a TableView and I want to know how to programmatically change the style from single to grouped?

Regards,

Ghost

EDIT:

Nevermind i figured it out, however if people are wondering what i was wondering it is
Code:
- (id)initWithStyle: (UITableViewStyle)style {
if (self = [super initWithStyle:UITableViewStyleGrouped]) {
}
return self;
}
 
Last edited by a moderator:

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
You sure you wanna ignore initWithStyle:'s style parameter value? Why not just change the call to initWithStyle: to something like:
Code:
[tableView initWithStyle:UITableViewStyleGrouped];
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Actually I would change it this way

Code:
// MyViewController
- (id)init {
     if ((self = [super initWithStyle:UITableViewStyleGrouped])) 
     {
     }
     return self;
}

// Creation
MyViewController* controller = [[MyViewController alloc] init];
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Having a parameter that your code ignores, as you show, doesn't make much sense. I always like my view controllers to keep the name of their nib private and the style in this case doesn't need to be known by other classes.

The way you show will work correctly.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.