在UIPopover中显示时,UINavigationController的内容偏移量 [英] UINavigationController content offset when displayed in UIPopover

查看:86
本文介绍了在UIPopover中显示时,UINavigationController的内容偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个视图,可以加载到UINavigationController中,并在iPad上以弹出窗口的形式显示,或者在iPhone上以模式视图的形式呈现。

I have a view which I load into a UINavigationController and present either as a popover on iPad or a modal view on iPhone.

我遇到的怪异现象是也就是说,当该导航栏显示在弹出窗口中时,其内容似乎偏移或下移了约60个像素。下面是此现象的屏幕截图。

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.

之所以这样显示,是因为我将最高限制设置为80,以补偿iPhone。如果我将其设置为更直观的值(例如10或20),则标签将完全隐藏在iPhone导航栏下方,而弹出窗口则显示正确。

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 :-(

预先感谢。

推荐答案

尝试在StoryBoard上进行设置调整滚动视图插入并检查扩展边缘设置。

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 

这篇关于在UIPopover中显示时,UINavigationController的内容偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆