我有一个带有导航栏的应用程序。
当我单击应用程序中的照片预览时,它会全屏显示照片。但是当我关闭全屏时,我的控制器的视图位于导航栏下方。
我在 StackOverflow 上看到有必要添加这一行:
self.edgesForExtendedLayout = []
它可以工作,但会产生另一个错误。
所以我想知道是否还有其他选择?
UPDATE :
1-使您的导航栏不透明。
self.navigationController.navigationBar.translucent = NO;
2- If you are using Xib then check “Safe Area Layout Guides” in the File Inspector as shown below.
3-如果您想以编程方式执行此操作,则在添加视图后
self.yourView.translatesAutoresizingMaskIntoConstraints = false;
if (@available(iOS 11, *)) {
UILayoutGuide * guide = self.view.safeAreaLayoutGuide;
[self.yourView.leadingAnchor constraintEqualToAnchor:guide.leadingAnchor].active = YES;
[self.yourView.trailingAnchor constraintEqualToAnchor:guide.trailingAnchor].active = YES;
[self.yourView.topAnchor constraintEqualToAnchor:guide.topAnchor].active = YES;
[self.yourView.bottomAnchor constraintEqualToAnchor:guide.bottomAnchor].active = YES;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)