iOS 8 - UIPopoverPresentationController moving popover

后端 未结 6 1292
遇见更好的自我
遇见更好的自我 2020-12-25 13:40

I am looking for an effective way to re-position a popover using the new uipopoverpresentationcontroller. I have succesfully presented the popover, and now I want to move it

6条回答
  •  孤城傲影
    2020-12-25 14:20

    I used the same method as mentioned in another answer by @Rowan_Jones, however I didn't want the popover's size to actually change. Even by fractions of a point. I realized that you can set the preferredContentSize multiple times back to back, but visually it's size will only change to match the last value.

    [vc.popoverPresentationController setSourceRect:newSourceRect];
    CGSize finalDesiredSize = CGSizeMake(320, 480);
    CGSize tempSize = CGSizeMake(finalDesiredSize.width, finalDesiredSize.height + 1);
    [vc setPreferredContentSize:tempSize];
    [vc setPreferredContentSize:finalDesiredSize];
    

    So even if finalDesiredSize is the same as your initial preferredContentSize this will cause the popover to be updated, even though it's size doesn't actually change.

提交回复
热议问题