Table View in a content View controller of a popover not resizing properly

822 Views Asked by At

Background: I have a View controller which has a header view(UIView), a footer view (UIView), table view and a search bar(UISearchBar) above it . This is made using xib. I need to present this inside a popover. This is done and everything is working fine.

Problem: The problem begins when i launch the key pad for search. The key board shrinks the size of the popover. Because of this i cannot see the bottom cells of my table. I have no idea why. My guess is its not getting resized properly.

What i tried: I tried to reduce the height of the table using keyboard notifications. It works but i want a more elegant solution and also want to what i am doing wrong ?

This is specific to iOS 6.0. It works fine with 7.0

EDIT On further testing i found out that my solution is not working :(

Any help is highly appreciated. Thanks

View controller xib schema: enter image description here

1

There are 1 best solutions below

2
On

Make sure you set the desired size of your view controller within the popover. This is done in two ways: You can override the method contentSizeForViewInPopover on the view controller that you are displaying within a popover, like so:

- (CGSize)contentSizeForViewInPopover
{
    // return the size WITHOUT a navigationbar height
    return CGSizeMake(320, 300);
}

And/or you can set a property on the popover, like so:

// if your inner viewcontroller is a UINavigationViewController, return the size WITH the   
// navbar height
self.popover.popoverContentSize = CGSizeMake(320, 344);

Notice the comments.