Changing UITableView width

Changing UITableView width

I’m back to programming and currently developing application for iPad. I needed something, what looked like a simplest thing – UITableView taking a portion of screen and SplitViewController wasn’t attractive option. To my surprise non of the obvious to me solutions worked until I’ve tried not-so-elegant reallocating of tableView.

So, in myTableViewController I created custom init function:

- (id) initWithFrame:(CGRect)frm {
if ((self = [super initWithStyle: UITableViewStylePlain])){
self.tableView = [[UITableView alloc] initWithFrame:frm style:UITableViewStylePlain];
}
return self;
}

Obviously, you can use default or your own init function or avoid passing frame argument and hardcode dimensions right here, but the magical line is:

self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(x, y, width, height) style:UITableViewStylePlain];

Well, at least it worked for me.

你可能感兴趣的:(Changing UITableView width)