问题
I have a view which I load into a UINavigationController and present either as a popover on iPad or a modal view on iPhone.
The weirdness I'm experiencing is that, when this nav is presented in the popover, it's content appears offset, or pushed down, by about 60 pixels. Below are screenshots of this phenomenon.
It currently appears this way because I have my top constraint set to 80, compensating for the iPhone. If I Set it to something more intuitive like 10 or 20, the label would be totally hidden under the iPhone nav bar while the popover would appear correct.
Any suggestion? I know I can manually adjust top constraint based on whether it's in a modal or a popover, but I'd rather change some property on the navigation bar to disable the offset or something like that since using device idioms is deprecated by Apple now :-(
Thanks in advance.
回答1:
Try setting on StoryBoard the Adjust Scroll View Insets and check the Extended Edges settings.
@property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets NS_AVAILABLE_IOS(7_0); // Defaults to YES
@property(nonatomic,assign) UIRectEdge edgesForExtendedLayout NS_AVAILABLE_IOS(7_0); // Defaults to UIRectEdgeAll
@property(nonatomic,assign) BOOL extendedLayoutIncludesOpaqueBars NS_AVAILABLE_IOS(7_0); // Defaults to NO, but bars are
来源:https://stackoverflow.com/questions/26238481/uinavigationcontroller-content-offset-when-displayed-in-uipopover