ios Xcode 8 Swift 3 中出现的“导航栏”警告框在运行时会有所不同

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39621140/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 10:17:55  来源:igfitidea点击:

Warning frame for "Navigation bar" will be different at run time appears in Xcode 8 Swift 3

iosswiftxcodeuinavigationbarxcode8

提问by Danny

Before I've upgraded to Xcode 8I haven't seen this error in such case. I have different Navigation Controllers. For all of them I see an error Frame for "Navigation bar" will be different at the run time. Navigation bar "Expected: width=384, Actual: width=375. In reality these Navigation Controllers doesn't have Navigation bar. Navigation barexists for subviews. Anyway I could solve it by tick and untick the checkbox Shows navigation barin Attributes inspector. But unfortunately every time I reopen Main.storyboardthis warning appears again. Also if I click on yellow triangle and then on update frames nothing happen.

在我升级到Xcode 8这种情况之前,我还没有看到这个错误。我有不同的导航控制器。对于他们所有人,我看到了一个错误Frame for "Navigation bar" will be different at the run time. Navigation bar "Expected: width=384, Actual: width=375。实际上,这些导航控制器没有Navigation bar. Navigation bar存在于子视图中。无论如何,我可以通过勾选并取消勾选Shows navigation bar中的复选框来解决它Attributes inspector。但不幸的是,每次我重新打开Main.storyboard这个警告时都会再次出现。此外,如果我单击黄色三角形,然后单击更新帧,则什么也不会发生。

enter image description here

在此处输入图片说明

回答by Kai

Warning will disappear if you change the property "Simulated Size" to "Freeform".

如果将“模拟尺寸”属性更改为“自由形式”,警告将消失。

回答by buildsucceeded

As mentioned hereyou can fix this by toggling Adjust Scrollview Insets on/off.

正如这里提到的您可以通过打开/关闭调整滚动视图插入来解决此问题。

回答by negersiu

I have changed from View as: iPhone 6S to iPhone 5S, then changed back to iPhone 6S, and Xcode did all the changes to remove the warning.

我已从 View as: iPhone 6S 更改为 iPhone 5S,然后又改回 iPhone 6S,Xcode 做了所有更改以消除警告。

回答by guoc

This worked for me at Xcode 8.3.1 After restarting Xcode, it would still work.

这在 Xcode 8.3.1 对我有用 重新启动 Xcode 后,它仍然可以工作。

enter image description here

在此处输入图片说明

  1. Select Navigation Controller
  1. 选择导航控制器

enter image description here

在此处输入图片说明

  1. Go to Show the Size Inspector
  1. 转到显示尺寸检查器

enter image description here

在此处输入图片说明

  1. Change Simulated Size to Freeform
  1. 将模拟尺寸更改为自由形式

enter image description here

在此处输入图片说明

  1. Change Simulated Size back to Fixed
  1. 将模拟尺寸改回固定尺寸

enter image description here

在此处输入图片说明

  1. Then the warnings disappear.
  1. 然后警告消失。

enter image description here

在此处输入图片说明

回答by Jensie

As a workaround just to get rid of the annoying warning I have been editing Main.storyboard manually by removing 'misplaced' in:

作为一种解决方法,只是为了摆脱烦人的警告,我一直在通过删除“错位”来手动编辑 Main.storyboard:

<navigationBar key="navigationBar" opaque="NO" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="Os1-Xh-7XN">

A hack but it is nice to have zero warnings rather than 1 :)

一个黑客,但有零警告而不是 1 很好:)

回答by colby

Click "View As" at the bottom left of your storyboard and choose a different device size, then click it again and swap back to the device size you started with. This worked for me.

单击故事板左下角的“查看为”并选择不同的设备尺寸,然后再次单击它并切换回您开始使用的设备尺寸。这对我有用。

回答by UKDataGeek

I tried all the above suggestions but it didn't seem to work. I think it might be a more serious bug.

我尝试了上述所有建议,但似乎没有用。我认为这可能是一个更严重的错误。

I have logged a bug with Apple Bug Reporter( link: https://bugreport.apple.com/logon) - if you want to do the same, then please reference bug : 31355220so that Apple can tie it together. The more people that report it - the more information they will have to fix this annoyance.

我已经使用 Apple Bug Reporter(链接:https: //bugreport.apple.com/logon)记录了一个错误- 如果您想这样做,请参考错误:31355220以便 Apple 可以将其绑定在一起。报告它的人越多 - 他们需要解决这个烦恼的信息就越多。

回答by nekonari

Until Xcode 8 is patched, you can set the "View as:" option to "iPhone SE" to eliminate the warning. Not ideal, but works for now.

在修补 Xcode 8 之前,您可以将“查看为:”选项设置为“iPhone SE”以消除警告。不理想,但目前有效。

回答by templeman15

I was able to get rid of the issue completely by setting the simulated size of the view controller to freeform and then setting the width from 375 to 320.

通过将视图控制器的模拟大小设置为自由格式,然后将宽度从 375 设置为 320,我能够完全摆脱这个问题。

回答by Radu Ursache

for me the problem was that i was hiding the bottom bar on push (using IB checkbox).

对我来说,问题是我在推送时隐藏了底部栏(使用 IB 复选框)。

i had to select 'none' in 'bottom bar' option:

我不得不在“底栏”选项中选择“无”:

enter image description here

在此处输入图片说明