UIPopoverController automatically resizing to max height on pushViewController

后端 未结 13 659
感情败类
感情败类 2020-12-07 10:45

I have a popover containing a UINavigationController. I can display the popover fine, and it contains the navController just fine. The navController contains a tableView a

13条回答
  •  暖寄归人
    2020-12-07 11:34

    Slight varient on borked's advice (which pointed me in the right direction, thanks for that!), here's what I do when pushing a new controller to maintain the size before pushing it:

    productViewController.contentSizeForViewInPopover = self.view.bounds.size;
    self.contentSizeForViewInPopover = self.view.bounds.size;
    
    [self.navigationController pushViewController:productViewController animated:YES];
    

    I like this because I don't have to hardcode the popover values in every view controller (good since I use them at various heights).

    The self.contentSizeForViewInPopover line is to preserve the size when the user hits back. I guess you could put this line somewhere else, like viewWillAppear or wherever you like.

    Seems to work...

提交回复
热议问题