143

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Danny
  • 3,975
  • 4
  • 22
  • 35

14 Answers14

153

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

croxy
  • 4,082
  • 9
  • 28
  • 46
Kai
  • 1,658
  • 1
  • 8
  • 3
  • 37
    This doesn't solve problem. Close Xcode and Open again the issue will come again. – Ashish Kakkad Sep 23 '16 at 04:44
  • @AshishKakkad And there is! Used to do the same and become normal, but then again it's a warning there... – AlessandroDP Sep 27 '16 at 09:14
  • 2
    This is bugging the hell out of me.. I just tried this, and this does remove warning *temporarily*. You can always switch Simulated Size back and forth to remove the warning when it does come back. Super. Annoying. – nekonari Oct 03 '16 at 18:55
  • 5
    Only a temporary fix - this is not the answer. – emem Nov 23 '16 at 15:56
  • You may still see this error if you don't manually change the size to the suggested. – Micah Montoya Nov 23 '16 at 20:08
  • Solved my problem. Thanks @Kai – nodyor90z Dec 23 '16 at 22:29
  • 5
    Either change this Simulated Size (and back to 'Inferred' or whatever) or _"toggling Adjust Scrollview Insets on/off"_. Both will cause Storyboard to remove its `misplaced="YES"`. This is an Xcode bug, and this fix is a force-refresh kind. **Taken from @buildsucceeded answer.** – bauerMusic Jan 04 '17 at 06:57
  • @bauerMusic what do you mean a force refresh kind? – UKDataGeek Mar 30 '17 at 21:17
  • 1
    @MobileBloke By force-refresh I meant that it will cause the Storyboard view to rewrite (refresh) the params, re-evaluate and remove the warning. It's really a refresh, force was only meant that it didn't do it automatically by itself (as it should) and needed some manual arbitrary change. – bauerMusic Mar 31 '17 at 07:51
  • Makes sense - I thought there was a magic button . I noticed that storyboard is taking longer to load since this bug started appearing .. you seeing this too ? – UKDataGeek Mar 31 '17 at 07:53
  • Xcode is a sea of unsolved bugs that continue there, marinating, forever. – Duck Aug 20 '17 at 23:57
  • I could only make it go away permanently (even after restart) by using the width that appeared in the warning, as the value in the Freeform option. – Efren Sep 13 '17 at 01:04
35

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

Community
  • 1
  • 1
buildsucceeded
  • 4,203
  • 4
  • 34
  • 72
15

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.

negersiu
  • 552
  • 3
  • 20
  • 2
    This worked for a short time- then after Xcode procesed it again - the same thing happened and the warning re-occured. Is this still working for you on latest Xcode? – UKDataGeek Apr 16 '17 at 11:40
12

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

guoc
  • 414
  • 4
  • 6
  • Any idea why this would have worked and not "Update frames" button? – Manganese Sep 18 '17 at 07:08
  • @guoc, bro could you help me please https://stackoverflow.com/questions/46375778/add-navigation-bar-in-uicollectionview-in-swift-4-ios-11 ? – May Phyu Sep 23 '17 at 03:56
7

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

Jensie
  • 611
  • 5
  • 9
  • Will I have to add this back later? I don't really care what my navigation Controller looks like so long as I don't have warnings. It's kind of funny. The storyboard recognizes the warning for a split second and then it goes away when you enter the storyboard this way. – Sethmr Nov 03 '16 at 17:10
  • I did the same thing and then don't touch the storyboard again. Everything works well. – Zhao Jan 05 '17 at 02:45
  • PRoblem is that when you reload it comes back... anyone else noticing that it takes a long time to load the storyboard with the spinner running when this error occurs? – UKDataGeek Apr 16 '17 at 11:03
6

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.

innesngunn
  • 331
  • 1
  • 8
3

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.

nekonari
  • 480
  • 1
  • 6
  • 13
  • I am USING SE .. but still Warning – Abdul Waheed Nov 04 '16 at 03:58
  • 1
    Yeah, I know. But they do go away whenever you switch that selection to something else. Nowadays, I start with 7, switch to SE, then back to 7 to clear these warnings. Or just leave them, and just not check `misplaced` properties in when commiting changes. – nekonari Nov 07 '16 at 22:50
3

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.

UKDataGeek
  • 6,338
  • 9
  • 46
  • 63
2

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.

templeman15
  • 799
  • 8
  • 14
  • You only need to set it only on the view controllers that have no parents (root view controller + maybe more, depending on what you have in your storyboard) – thetrutz May 15 '17 at 13:57
1

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.

James Webster
  • 31,873
  • 11
  • 70
  • 114
1

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

Radu Ursache
  • 1,230
  • 1
  • 22
  • 35
0

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.

GregP
  • 1,584
  • 17
  • 16
  • 3
    After reopening of XCode this warning actually disappears, but if I open any file in the project an the again open `main.storyboard` these warnings appear again – Danny Sep 21 '16 at 20:25
0

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.

Ash
  • 5,525
  • 1
  • 40
  • 34
0

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.

Zhou Haibo
  • 1,681
  • 1
  • 12
  • 32