Heena
Heena

Reputation: 754

how to decrease the height of table of class UITableViewController?

I am using table view in a view controller which is UITableViewController. I am trying to set the height of table by

[self.tableView setFrame:CGRectMake(0, 0, 320, 300)];
[self.tableView setBackgroundView:backImageView];
    [self.tableView setSeparatorColor:[UIColor blackColor]];

but it is not working. It doesn't have XIB Is there any way to do that?

Upvotes: 0

Views: 178

Answers (2)

alex-i
alex-i

Reputation: 5454

For what I know you can't do that (IF you push/showModal the tableviewcontroller), the view (in this case a tableview) of viewcontrollers is resized automatically to the screen size (- status bar, navigationbar and tabbar). You can however set contentOffset and contentInset.

In your case this should work (might need to change the values):

self.tableView.contentInset = UIEdgeInsetsMake(0 /*top*/, 0/*left*/, 160/*bottom*/, 0/*right*/);

Upvotes: 2

Magic Bullet Dave
Magic Bullet Dave

Reputation: 9076

Difficult to say without some more detail. For instance, are you creating your UITableView object in your LoadView?

self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];

You also need to make sure you are adding your tableView to the view controller's view:

[self addSubView:tableView];

Hope this helps, but a bit more detail in your question would enable a more thorough answer. i.e., what does not work, etc.

Dave

Upvotes: -1

Related Questions