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:bac开发者_StackOverflow社区kImageView];
[self.tableView setSeparatorColor:[UIColor blackColor]];
but it is not working. It doesn't have XIB Is there any way to do that?
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*/);
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
精彩评论