0
votes

When presenting an UINavigationController within an UIPopoverController I let the popup know its size. So given we are within any UIViewController that shall display the popup we would do:

MYNavigationController *fooController = [self.storyboard instantiateViewControllerWithIdentifier:@"fooController"];
self.popover = [[UIPopoverController alloc] initWithContentViewController:fooController];
self.popover.popoverContentSize = CGSizeMake(600, 400);
[self.popover presentPopoverFromRect:CGRectMake(0, 0, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

However, when I push another UIViewController on top of fooController that pushed view controller will change the popover's size. I did not force any content size change programmatically. That view controller is not calling self.contentSizeForViewInPopover = CGSizeMake(400, 300); as I really would like to avoid to let all view controllers know that they are within a popover controller. This might be also the reason that this method is even deprecated from iOS 7 on. There's another property called preferredContentSize that is available only for iOS 7, however this also does change the popover's content size.

So my questions are:

  1. Why does the popover's content size change?

  2. Why does the UIPopoverController have a popoverContentSize property when pushed view controllers automatically overwrite this size - without me as the programmer doing nothing?

  3. How can I prevent the pushed view controller from changing its content size?

1

1 Answers

0
votes

Assuming iOS 7 set preferredContentSize property of each view controller instance. You can set regardless of whether an instance is used in popover or not. If earlier iOS version support needed set contentSizeForViewInPopover instead when running on earlier versions. You could create a UIViewController subclass that all your VCs are derived from to implement this.