Created
November 4, 2014 23:31
-
-
Save fatuhoku/472a78f6dbbd101a178f to your computer and use it in GitHub Desktop.
Make popover resize according to the preferredSizes of ViewControllers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Conform to UINavigationControllerDelegate and then implement this: | |
// Especially if the topViewController is a RBStoryboardLink or something. | |
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { | |
// NB: Using navigationController.preferredContentSize would be better here, but it doesn't reset properly when navigating back so we manually add on the height of the navbar instead. | |
CGSize size = viewController.preferredContentSize; | |
CGFloat navbarHeight = navigationController.navigationBar.frame.size.height; | |
<topViewController>.preferredContentSize = CGSizeMake(size.width, size.height + navbarHeight); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment