user626912
user626912

Reputation: 2560

Trying to resize a UITableView to fit screen on iPad

I am trying to resize a simple UITableView that fits between a navigationbar and a tabbar.

- (void)loadView 
{
    [super loadView];   

    UITableView *tableview = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 367.0f) style:UITableViewStylePlain];
    tableview.dataSource = self;
    tableview.delegate = self;
    self.tableView = tableview;
    [tableview release];

    [self.view addSubview:self.tableView];
}

I have removed the autoresizing I have been trying to do because it does not work, any help is MUCH appreciated!

Upvotes: 1

Views: 2619

Answers (2)

Sean S Lee
Sean S Lee

Reputation: 1294

1) Create your view programmatically in loadView, do not call [super loadView]

2) create tableView with size same as application screen, use [[UIScreen mainScreen] applicationFrame] or something similar

3) set UIViewAutoresizingFlexibleHeight for tableView

..Edited answer to be more clear..

Upvotes: 1

hoha
hoha

Reputation: 4428

tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth
tableView.frame = self.view.bounds;
[self.view addSubview:tableView];

Upvotes: 1

Related Questions