Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I don't know auto-layout properly. So, I am using autoresizing option in my all apps and it's fine for me. I am able to fulfill my all requirements by this without any issue.

Now in Xcode 8, I have migrated my old swift project to swift 3. Now issue arises.

Storyboard SS

See in image, I have set Autoresizing, and its working fine without issue in all devices until now and this project is live in AppStore, so that I can't show the UI or storyboard.

Now I have to do some update in project. So I am working in Xcode 8 now. But my autoresizing not working properly, as all the controls are come in center and UI is messed up.

Output image

And the issue persists in device also. I have checked in simulator and device as well. But problem is there also. Any suggestion and help will be appreciated. Thanks in advance.

EDIT:

Yesterday there is issue in runtime only, But Today storyboard also changed views like this image

Storyboard image

Which means the whole UI design is messed up. This is weird.

share|improve this question
    
same here ... and its a bug in xcode ... and there is issue with auto layout too stackoverflow.com/questions/39394316/… – EI Captain v2.0 Sep 16 at 7:39
    
@EICaptainv2.0 ok but there is an answer to update frames. But what to do in this case? – Max Sep 16 at 7:44
1  
nothing in this case ... because I did try everything but nothing works for me – EI Captain v2.0 Sep 16 at 7:45
    
This happen for all view inside Scrollview only? – CRDave Sep 17 at 5:09
    
@CRDave No. Not only scrollview, All other view controllers without scrollview also have same issue. Only tableview cell are stable with no change. – Max Sep 17 at 5:23

Facing same issue. As a my point of view this problem is occurred when we use autoresizing and set only inner autoresizingMask to any view controller. Like,

enter image description here

If we use also boundary autoresizingMask at that time not facing this issue. Like,

enter image description here

I don't know this is actual bug of xcode 8 or remove this functionality in xcode 8.

So, Finally my suggestion is that we need to use auto layout in xcode 8.

share|improve this answer
1  
This is not an answer. Please make an appropriate answer, or wait for a solution from the public. – pedrouan Sep 17 at 7:55
    
@pedrouan, See my edited ans. – Keyur Hirani Sep 19 at 4:43
    
this is not an answer either. Answer is meant to be a solution and you last sentence, if it could be the solution, is supposed to be posted rather as a comment. – pedrouan Sep 19 at 6:04
    
yep, the bug is serious and still there, we must be able to disable AutLayout too and have no issues on Storyboard, as we always could do up to Xcode 7.3.1 – fvimagination Sep 19 at 12:26
    
This is how Apple force you to use autolayout. Make autoresize break your app. – Rocotilos Sep 30 at 11:10

Please try to uncheck autoresizing from xib or storyboard. And in viewdidload [_scrollView setAutoresizesSubviews:YES];

Try it if this solve your problem

Edit: In case of storyboard uncheck 'Resize view from NIB' option.

share|improve this answer
    
thanks, that's really helps me :) – andrew92b Sep 22 at 9:57
1  
in my case it brings 80% UI to its original place but when I try to correct 20% myself using storyboard, things get horrible... How can Apple ship Xcode 8 without testing old project compatibility with it – Abdul Hannan Sep 26 at 15:52
    
this doesn't worked for me. – gstream79 Sep 28 at 6:47

I'm not sure about storyboards but I've found a temporary solution for xib files. In Utilities panel (right hand panel) select File Inspector tab. Under Interface Builder Document section, select the file to open in "XCode 7.x". It will ask you to confirm that you do not want to use XCode 8 features, save the file and close it.

enter image description here

share|improve this answer
1  
It will lock the storyboard that time only.. Again when you access storyboard it will use 8.0. – Max Sep 29 at 12:45
    
Yes, unfortunately I need to do the same thing every time I edit the file. – Srdr Sep 29 at 12:46
1  
Thats why this is not a solution, It can work until we got perfect and steady solution. – Max Sep 29 at 12:48
    
As i said this is a temporary way to make it work till Apple updates XCode and solves the issue. – Srdr Sep 29 at 12:49
    
thanx your temporary solution working well ... – seggy Oct 12 at 5:29

Having the same issue and I've found that the offender here is the UIScrollView element. Just move everything outside of your scroller and you will see that everything works just fine, like before.

Which means one possible workaround would be to place your scrollable content in an ordinary UIView, then replacing it with UIScrollView at run time, programmatically.

share|improve this answer
    
There are many views without scrollview and also have same issue. And Scrollview only is not problem. – Max Sep 20 at 4:42
    
@Max have you tried to move everything outside the scroller and see if it works? It worked for me. – mojuba Sep 20 at 10:43

i also face same issue for scrollView in Xcode8

i have a one solution to work with scrollView

first take a simple UIView and add all component which you want add to in scrollView and give that component to autoSizing

and also take one scrollView and programatically set view frame and also set scrollView contentSize and add your view into scrollView

like wise, in my case i add this code in viewDidLoad for swift project

// add view to scrollview

self.scrollObjForNextAppointment.contentSize = CGSize(width:self.scrollObjForNextAppointment.frame.size.width,height:410)

self.viewForScrollContent.frame = CGRect(x:0,y:0,width:self.scrollObjForNextAppointment.frame.size.width,height:410)

self.scrollObjForNextAppointment.addSubview(self.viewForScrollContent)

it's work for me, Thanks!

share|improve this answer
    
What about storyboard which mess up the views UI? Each time we need to set it? – Max Oct 3 at 8:47
    
not need to set everytime, it's only happen in scrollView, not in view – Sapana Ranipa Oct 3 at 9:29
    
Then if we use scrollview by code only then no need to use in storyboard, Thats not proper solution for interface builder. – Max Oct 3 at 10:02
    
you can take scrollView in storyboard, not need to add scrollView by coding, just take empty scrollView not add any UIComponent in that scrollView, take another view in storyBoard and in that add your all component and give them to autoSizing and add that view in scrollview by coding. – Sapana Ranipa Oct 3 at 10:08
    
There is no difference if we take blank scrollview in storyboard or add it through code, in this scenario. – Max Oct 3 at 10:21

I think it is xcode bug with autoresizing and I have already report a bug to apple bug report support and waiting for their reply.

share|improve this answer
1  
This is not an answer. Please make an appropriate answer, or wait for a solution from the public. – Max Sep 20 at 5:04

Solved by unchecking "Auto Resize Subviews" to ScrollView

enter image description here

share|improve this answer
    
but i need to resize it according to screen size. – Max Sep 20 at 4:40
    
It solves the problem but we have to deal with Different Screen sizes – Hassy Sep 20 at 12:36
    
In my case there is no problem for different screen sizes, don't remove the auto resize properties for scrollview. – Thippi Sep 21 at 9:57
1  
in my case I am not using autolayouts – Thippi Sep 21 at 9:58

A moderator kindly deleted my answer here as a duplicate, so see my answer at:

Autoresizing under iOS 10 doesn't work

In response to max, yes, resizing a bunch of subviews can be a pain. That's why I suggested adding a single "content view" to the scroll view and moving all of your existing subviews inside of that view. Autosize the subviews inside of the content view just as you did with the scrollview, and autosize the content view to the scrollview.

It's that content view that you're then resizing inside viewDidLayoutSubviews.

And again, the "content view" inside of the scrollview construct is pretty much the standard way to get auto-sizing scroll views using autolayout, so it should be considered a best practice.

That method is described here...

https://spin.atomicobject.com/2014/03/05/uiscrollview-autolayout-ios/

My method seems a little convoluted, but I was able to patch up a storyboard with about a dozen scenes and Vc's in about 15 minutes. It would have taken much, much, much longer to rebuild everything using auto layout.

share|improve this answer

protected by Community Oct 1 at 13:42

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.