简体   繁体   English

iPhone X - 安全区布局指南 - 我希望我的应用全屏显示,而不仅仅是在安全区

[英]iPhone X - safe area layout guides - I want my app display on full screen, not only in the safe area

I have a problem with my code.我的代码有问题。 My application displays within iOS safe area layout guide, however I'd like to force it to display "outside".我的应用程序显示在 iOS 安全区域布局指南中,但是我想强制它显示“外部”。 I have searched the internet and unfortunately I found only "reverse" problems.我在互联网上搜索过,不幸的是我只发现了“反向”问题。 I don't use interface builder, all my views I create programmatically.我不使用界面构建器,我以编程方式创建的所有视图。 I have a main view controller which starts up automatically with the app and from here I start creating all my stuff.我有一个主视图控制器,它会随应用程序自动启动,从这里我开始创建我所有的东西。 My interface builder just shows this view controller and a view assigned to it.我的界面构建器只显示这个视图控制器和分配给它的视图。 Interestingly, the view appears to be really full screen when viewed in IB.有趣的是,在 IB 中查看时,该视图似乎是全屏显示。

Yes, I tried turning on/off the "Use Safe Area Layout Guide" option for the view.是的,我尝试打开/关闭视图的“使用安全区域布局指南”选项。 Also I tried to use topLayoutGuide and bottomLayout guide instead and constrain the main view to them, but it still fails:此外,我尝试使用 topLayoutGuide 和 bottomLayout guide 并将主视图限制为它们,但它仍然失败:

- (void)viewDidLoad {
     [super viewDidLoad];
     UILayoutGuide *margins = self.view.safeAreaLayoutGuide;
     [NSLayoutConstraint activateConstraints:@[[self.view.topAnchor constraintEqualToAnchor:self.topLayoutGuide.topAnchor],
                                          [self.view.bottomAnchor constraintEqualToAnchor:self.bottomLayoutGuide.bottomAnchor]
                                          ]];

     //...
}

This is what I see in the IB:这是我在IB中看到的:

1) view 1) 视图

在此处输入图片说明

2) safe area - I can't get rid of it in any way: 2)安全区——我无法以任何方式摆脱它:

在此处输入图片说明

3) result (simulator / real device): 3)结果(模拟器/真机):

在此处输入图片说明

I also did RTFM but a) I'm stupid, b) I'm too tired, c) both我也做过 RTFM,但是 a) 我很笨,b) 我太累了,c) 两者都

Any help would be appreciated :)任何帮助,将不胜感激 :)

If you use constraints on the view, it will usually automatically align to the safe area.如果在视图上使用约束,它通常会自动对齐到安全区域。 You can override this and have it constrain to the superview instead by clicking the little arrow to the right for a drop down menu:您可以覆盖它并将其约束到超级视图,而不是通过单击下拉菜单右侧的小箭头:

在此处输入图片说明

You then select "View" instead of "Safe Area".然后选择“查看”而不是“安全区域”。 Also make sure to un-click "Constrain to margins" or it still won't fill out the whole screen.还要确保取消单击“约束到边距”,否则它仍然不会填满整个屏幕。

I resolved my issue.我解决了我的问题。 The application was not displaying in full screen because of missing launch image in my assets for iPhone XR.由于我的 iPhone XR 资产中缺少启动图像,该应用程序未全屏显示。 Because of this iOS was falling back to the closest launch image keeping aspect ratio, thus defining the application size.由于这个原因,iOS 回退到最接近的启动图像保持纵横比,从而定义了应用程序的大小。

The second issue (not loading the image, displaying some default splash screen insead) - removing the app from device and installing from scratch helped.第二个问题(不加载图像,显示一些默认的启动画面 insead) - 从设备中删除应用程序并从头开始安装有帮助。

Thanks everyone involved :)谢谢大家参与:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM