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.

Tags: , ,

3 responses

  1. Posted September 21, 2010 at 03:00 | Permalink

    Hi,

    i wanted the width and height fixed on a uitableviewcontroller. when it scrolls it occupies the whole screen and i dont see my buttons or any controls for that matter.

  2. Posted November 18, 2010 at 19:21 | Permalink

    merely have got to say you help to make various fantastic facts and will write-up a handful of concepts to add on as soon as a day or two.

Leave a Reply