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

IosSwiftXcodeUinavigationbarXcode8

Ios Problem Overview


Before I've upgraded to Xcode 8 I 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 bar exists for subviews. Anyway I could solve it by tick and untick the checkbox Shows navigation bar in Attributes inspector. But unfortunately every time I reopen Main.storyboard this warning appears again. Also if I click on yellow triangle and then on update frames nothing happen.

enter image description here

Ios Solutions


Solution 1 - Ios

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

Solution 2 - Ios

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

Solution 3 - Ios

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.

Solution 4 - Ios

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

enter image description here

  1. Select Navigation Controller

enter image description here

  1. Go to Show the Size Inspector

enter image description here

  1. Change Simulated Size to Freeform

enter image description here

  1. Change Simulated Size back to Fixed

enter image description here

  1. Then the warnings disappear.

enter image description here

Solution 5 - Ios

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

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

Solution 6 - Ios

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.

Solution 7 - Ios

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.

Solution 8 - Ios

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 : 31355220 so that Apple can tie it together. The more people that report it - the more information they will have to fix this annoyance.

Solution 9 - Ios

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.

Solution 10 - Ios

Had the same issue, here's what I did to fix:

Expand the error information and click on the warning detail. Xcode should then automatically open the dimension/position settings. Replace the current value with the value suggested in the warning details.

enter image description here

Basically, make sure that the size in your runtime is the same as the size you have specified in the size inspector.

You can also click the icon beside the image you posted (the yellow triangle with white circle. Sometimes, its a red circle icon) then there will be options to automatically fix/adjust the issues.

enter image description here

I chose the update constraints option then adjusted the new constraints accordingly.

Solution 11 - Ios

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

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

enter image description here

Solution 12 - Ios

Okay so it looks like I've fixed the issue. Here's what I did.

Select update frames like normal. Open a different file and then click back on the storyboard file. If that doesn't work then restart Xcode. It looks like it was updating internally but the interface builder UI was stuck as it sometimes gets.

Solution 13 - Ios

Please change your device Preview in xcode for View controller and compile and check for warnings...

Xcode 8 is bit buggy, Interface builder reset its with random no which affects all contained views. Try changing your preview device.

Solution 14 - Ios

Xcode 12

I think this problem is mostly because the width of device preview is different per various devices. E.g. iPhone 12 and iPhone 11 have different screenWidth. If you set a fix value on width of some view and give it some constraints, then it may not adopt your current previewed iPhone's screen width, so it complained "different size in run time".

And for me, I set an UIView and ImageView's width & height as fixed value in size inspector with iPhone 11 preview. And gives it also fixed 10 points leading and trailing constraints in IB. Then it complained if I switch to iPhone 12 preview.

To fix it, I select the viewController and chose "Update Frames". Then it looks better but Xcode still complain one conflict constraint after the change. Eventually, I manually found and fix it in IB.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDannyView Question on Stackoverflow
Solution 1 - IosKaiView Answer on Stackoverflow
Solution 2 - IosbuildsucceededView Answer on Stackoverflow
Solution 3 - IosnegersiuView Answer on Stackoverflow
Solution 4 - IosguocView Answer on Stackoverflow
Solution 5 - IosJensieView Answer on Stackoverflow
Solution 6 - IosinnesngunnView Answer on Stackoverflow
Solution 7 - IosnekonariView Answer on Stackoverflow
Solution 8 - IosUKDataGeekView Answer on Stackoverflow
Solution 9 - Iostempleman15View Answer on Stackoverflow
Solution 10 - Iosuser2027373View Answer on Stackoverflow
Solution 11 - IosRadu UrsacheView Answer on Stackoverflow
Solution 12 - IosGregPView Answer on Stackoverflow
Solution 13 - IosAshView Answer on Stackoverflow
Solution 14 - IosChuckZHBView Answer on Stackoverflow