George Morgan
George Morgan

Reputation: 677

How can I resize the table view in a UITableView controller?

I have a UINavigationController that contains the view of a UITableViewController. How can I resize the table view from within the navigation controller?

Upvotes: 1

Views: 2494

Answers (3)

Andrea Mario Lufino
Andrea Mario Lufino

Reputation: 7921

[[self tableView] setFrame:CGRectMake(0, 0, 320, 480)];

Upvotes: 1

Maybe this method will help you to resize the table rows:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

Upvotes: -1

Louie
Louie

Reputation: 5940

Not exactly sure if this is what you are looking for but its sounds close enough. This will resize your tableView to whatever pixel size you specify. It will do it in a transition too (so it doesnt just jump to size). You can remove the transition if you wanted.

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];

CGRect rect = myTableView.frame;
rect.size.height = 400;
rect.size.width = 300;
myTableView.frame = rect;
[UIView commitAnimations];

Upvotes: 2

Related Questions