I have a UIPopover
being display
Try to do the following for all UITableViewController, I tried it and it works for me!
- (void)setSize:(BOOL)fake
{
CGSize view_size;
int sections_height, rows_height;
//if you dynamically change the number of visible rows
//for example overriding numberOfRowsInSection:section
//this can help you to evaluate the correct popover height
int sections = [self.tableView numberOfSections];
int rows = 0;
for(int i = 0; i < sections; i++){
rows += [self.tableView numberOfRowsInSection:i];
}
sections_height = sections * 30 /*section height*/;
rows_height = rows * 44 /*row height*/;
view_size = CGSizeMake(320 /*fixed width*/, sections_height + rows_height);
if(fake){
view_size.width -= 1;
view_size.height -= 1;
}
[self setContentSizeForViewInPopover:view_size];
}
- (void)viewDidLoad
{
[super viewDidLoad];
//...
[self setSize:FALSE];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self setSize:TRUE];
}
- (void)viewDidAppear:(BOOL)animated
{
[self setSize:FALSE];
[super viewDidAppear:animated];
}