Animate popoverContentsize when pushing navigation view controller in popover on iPad

后端 未结 3 1440

How do I get my UIPopoverController to animate its size when its contained UINavigationController pushes a new controller?

I have a UIPopover being display

3条回答
  •  花落未央
    2021-02-07 11:57

    I think you were close if you tried keeping a reference to the popoverController and used setPopoverContentSize:animated:

    What works for me is this combination of setPopoverContentSize:animated: AND contentSizeForViewInPopover in that specific order, for each controller your put on the stack:

    -(void)viewDidAppear:(BOOL)animated
    {
        [self.popoverController setPopoverContentSize:whateverSize animated:true];
        self.contentSizeForViewInPopover = whateverSize;
        [super viewDidAppear:animated];
    }
    

    In this case, self.popoverController is a reference I keep in each controllers that is pushed on the stack, it would probably be cleaner to use a singleton variable for that.

提交回复
热议问题