65

I just finished an app on iOS 6 and bought a developer account a week ago so haven't had much time playing with the iOS 7 SDK. Just downloaded the Golden Master version and trying to upgrade my app to be compatible with iOS 7.

I received a lot of warnings saying

Misplaced View Frame for "Label - Label" will be different at run time.

and I am unable to run the program. The project contains tableview and its is parsing and displaying XML feed from an RSS.

How to fix this issue?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
AJ112
  • 5,291
  • 7
  • 45
  • 60
  • 1
    Xcode 5 and iOS 7 are still under NDA, you may not get any response to your question because of this. – rckoenes Sep 12 '13 at 07:38
  • @rckoenes Thanks. Shall i ask this question in Apple developer forum? – AJ112 Sep 12 '13 at 07:40
  • 1
    that would be the correct place. – rckoenes Sep 12 '13 at 07:41
  • Are you using autolayout with constrains? – Tarek Hallak Sep 12 '13 at 07:50
  • @null yes i am using Autolayout. Not sure what do you mean by constrains. There were autolayout errors earlier but i changed the deployment target from iOS 5 to iOS 6 and those errors were gone. But these warnings are still there. I want it to work on both iOS 6 and iOS 7. – AJ112 Sep 12 '13 at 07:53

5 Answers5

136

The accepted answer will fix the problem, but that's not a good solution because it'll remove all your constraints. If you have spent hours on the constraints then don't do that.

If you click the triangle next to the warning you can get the explanation of what is misplaced. Then you can just move the frame to where it's supposed to be. For example:

enter image description here

In this case I just moved my Text View's y position to 94 and the warning will go away. This is because one of my constraints will force the view to be somewhere else when the app is running, but the position is different than where it currently is in the storyboard.


Another way to move the frame to the right position is to click on the warning next to the View Controller name in your storyboard, and then click on the yellow warning sign, and click update frame.

enter image description here

enter image description here

These two methods are not destructive and will not remove your constraints. If anything it'll show that you may need to do minor readjustments in your constraints.

Enrico Susatyo
  • 19,372
  • 18
  • 95
  • 156
  • What if I want to use the size in the canvas and not what will be at run time? What will I do? – Gellie Ann Jul 10 '15 at 03:26
  • @GelFermis In general you'd have to rework your constraints, but try pressing "Update Constraints" first and it will try to do that for you. – Enrico Susatyo Jul 10 '15 at 05:05
  • @EnricoSusatyo I tried pressing "Update Constraints" and then "Fix Misplacement" but the warning is still there. Does that mean I'll have to rework my constraints? – Gellie Ann Nov 26 '15 at 23:41
  • it happens the same to me as for Gel Fermis.. I need to update frames every time I open the storyboard. is there any solution? This is the right solution, but doesn't fix my problem, since I need to update frames every-time I load the storyboard. Any solution? Thanks – Frade Feb 02 '16 at 19:42
46

I had the same issue and I get below response form Apple:

You need to update the constraints to match the frames of these views.

I did the following:

Editor -> Resolve Auto-Layout Issues -> Clear all constraints in ** view controller

then I reordered my objects again in the view.

PS: Try Enrico's solution first.

Tarek Hallak
  • 18,422
  • 7
  • 59
  • 68
  • 1
    Thanks it worked for me. Although i have to select the custom tableview cell and then using the "Clear all constraints" option. – AJ112 Sep 12 '13 at 12:56
  • 6
    This will clear your constraints! See Enrico's answert. – Apfelsaft Aug 25 '14 at 13:17
  • 1
    So if I added autoLayout to some views, and changed the frame accidentally or set just one view not correctly, you are saying that I need to clear the constraints, and leaving the views on static positions? What about the other views constraints, set up from the beginning? See @Enrico's Answer. – E-Riddie Oct 15 '14 at 14:50
  • @eridb what Static position ??!!! dah! who said that?? I've just reordered my constrains again. – Tarek Hallak Oct 15 '14 at 15:58
  • This is not the best way. Lets suppose you you have relative constraints to that view that you are removing its contraints. You just get full of warnings to missing constraints for the other views. If you clean them all, on complex views you have to study how you reordered your initial views. Why did Xcode add the ressolve layout constraints function? – E-Riddie Oct 15 '14 at 18:42
  • Agree but in some cases 'resolve layout' ruins the views, anyway you have both ways to try, happy coding ;) – Tarek Hallak Oct 16 '14 at 03:40
  • 1
    Yes I know that, but I wanted to tell you to update the answer, and tell other opportunities in order not to get dummy downvotes. I am not downvoting you because you know how this is done, just I am asking to make this question more valuable. P.S Judging by your name I am not sure you got the message, you have no address :P – E-Riddie Oct 16 '14 at 14:25
  • Sorry, but how is this an answer? The problem is seldom that the constraints are wrong, but rather that the position in IB doesn't correctly reflect them. – entonio Nov 05 '14 at 13:17
9

I had the same issue what you need to is , update the constraints or update the frame. On storyboard you have a small tool bar as shown in below image. enter image description here

Please see the meaning:-

enter image description here

You can either choose "Update Frames" or "Update Constraints" and Use "Reset to Suggested Constraints". This will resolve the issue regarding misplaced View. Don’t drag and drop views to make adjustments to layout. Edit the applicable constraints instead. Please , let me know if you not clear.

Sanoj Kashyap
  • 5,020
  • 4
  • 49
  • 75
6

If you are having troubles finding the Update Frames in xCode it can be done like so:

enter image description here

sivi
  • 10,654
  • 2
  • 52
  • 51
2

None of the answers work in all cases. As of recent version of Xcode, using a UISearchBar, enabling scoping field enabled in IB makes the search field appear double height (but doesn't show a the scoping bar beneath it). Whether or not you add a height constraint (of any height) to the search field, you'll get the warning that it is a misplaced view that will be 88 H at runtime but is 44 H in IB. Updating the frames (any or all frames) doesn't resolve it. Seems like a bug in IB.

clearlight
  • 12,255
  • 11
  • 57
  • 75
  • note: besides the annoying IB warning, the code runs fine and does the right thing (including showing the scoping bar) – clearlight Jan 29 '15 at 20:27
  • 1
    Yeah I keep updating the frame and it just moves one pixel up. The warnings are still there. Update Frame again, it moves down 1 pixel. This just goes on forever... When the code runs, its fine. – KorinW Mar 02 '16 at 11:12