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:
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];
 
Actually I would change it this way

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

// Creation
MyViewController* controller = [[MyViewController alloc] init];
 
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.