0

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

Prathamesh Saraf
  • 709
  • 4
  • 14
  • Are you using constraints? Have you tried setting controller.view.autoResizingMask = UIViewAutoResizingFlexibleHeight and tableView.autoResizingMask = UIViewAutoResizingFlexibleHeight and making your header and footer views the header and footer of the tableView? – George Green Jan 10 '14 at 11:23
  • @GeorgeGreen: Yup... the autoresizing masks are set in the xib. I forgot to mention.. no i am not using constraints. – Prathamesh Saraf Jan 10 '14 at 11:36
  • In your question, when you say "above it" you mean as subviews of its view right? Do you have a standard UITableView, or a subclass? Is autoresizing definitely set on all views in the hierarchy? Could you paste some of your code/a screenshot of IB? – George Green Jan 10 '14 at 12:42
  • @GeorgeGreen: Hi george. i did verify that my autoresizing masks are set for all views. I cannot upload the screen shot since it has been designed with specific wireframes. However i will attach a schema of the xib to help in understanding. Thanks for your time. – Prathamesh Saraf Jan 10 '14 at 13:22
  • Can you verify that viewWillLayoutSubviews is being called on your controller? – George Green Jan 10 '14 at 13:53
  • yup it is being called .. – Prathamesh Saraf Jan 10 '14 at 14:24
  • Hmmm... Ok, I'll have a proper look when I get home later! – George Green Jan 10 '14 at 14:34

1 Answers1

1

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.

Johannes Fahrenkrug
  • 42,912
  • 19
  • 126
  • 165