PDA

View Full Version : UITableView issue




GhostDZ9
May 18, 2011, 08:42 PM
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
- (id)initWithStyle: (UITableViewStyle)style {
if (self = [super initWithStyle:UITableViewStyleGrouped]) {
}
return self;
}



dejo
May 18, 2011, 09:28 PM
You sure you wanna ignore initWithStyle:'s style parameter value? Why not just change the call to initWithStyle: to something like:
[tableView initWithStyle:UITableViewStyleGrouped];

GhostDZ9
May 18, 2011, 10:20 PM
And where abouts would I put that piece of code?

PhoneyDeveloper
May 19, 2011, 06:54 AM
Actually I would change it this way

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

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

GhostDZ9
May 20, 2011, 08:35 AM
What difference would that make?

PhoneyDeveloper
May 20, 2011, 04:58 PM
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.