32

=== EDIT ========

This issue is now solved in Xcode 8.1. I have checked.

================

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.

Max
  • 2,269
  • 4
  • 24
  • 49

9 Answers9

7

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.

Keyur Hirani
  • 1,607
  • 14
  • 22
  • 1
    This is not an answer. Please make an appropriate answer, or wait for a solution from the public. – pedrouan Sep 17 '16 at 07:55
  • 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 '16 at 06: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 – Frank Eno Sep 19 '16 at 12:26
  • 1
    This is how Apple force you to use autolayout. Make autoresize break your app. – GeneCode Sep 30 '16 at 11:10
  • @Rocotilos I don't know this is bug or apple remove autoresize functionality . – Keyur Hirani Sep 30 '16 at 11:14
  • Hope it's a bug. But probably Apple don't care about an old feature. – GeneCode Oct 03 '16 at 04:30
  • **We need to use auto layout in xcode 8** That's it, no other way until Apple fix (if they want to fix it someday...) – Rémi Belzanti Oct 03 '16 at 10:58
  • See my fix below. It works in Xcode 8 and can be used as a stopgap measure until you're ready to bite the bullet and recode your storyboard using auto layout. – Michael Long Oct 06 '16 at 17:32
7

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

Try it if this solve your problem

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

spassas
  • 4,778
  • 2
  • 31
  • 39
Hassy
  • 5,068
  • 5
  • 38
  • 63
  • 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 '16 at 15:52
3

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

Srdr
  • 323
  • 2
  • 8
  • 1
    It will lock the storyboard that time only.. Again when you access storyboard it will use 8.0. – Max Sep 29 '16 at 12:45
  • Yes, unfortunately I need to do the same thing every time I edit the file. – Srdr Sep 29 '16 at 12:46
  • 1
    Thats why this is not a solution, It can work until we got perfect and steady solution. – Max Sep 29 '16 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 '16 at 12:49
2

I had a similar issue for scrollView in Xcode8

I have an 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 programmatically set view frame and also set scrollView contentSize and add your view into scrollView

like wise, in my case I added 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!

Sapana Ranipa
  • 889
  • 7
  • 20
  • What about storyboard which mess up the views UI? Each time we need to set it? – Max Oct 03 '16 at 08:47
  • not need to set everytime, it's only happen in scrollView, not in view – Sapana Ranipa Oct 03 '16 at 09: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 03 '16 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 03 '16 at 10:08
  • There is no difference if we take blank scrollview in storyboard or add it through code, in this scenario. – Max Oct 03 '16 at 10:21
2

Xcode 8 beta 2 solved this problem!! I already checkeded now!

Genevios
  • 1,115
  • 1
  • 16
  • 29
1

Update the issue seems to have been fixed in Xcode 8.1


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.

mojuba
  • 11,842
  • 9
  • 51
  • 72
  • 1
    There are many views without scrollview and also have same issue. And Scrollview only is not problem. – Max Sep 20 '16 at 04:42
  • @Max have you tried to move everything outside the scroller and see if it works? It worked for me. – mojuba Sep 20 '16 at 10:43
  • @mojuba is the UIScrollView not on self.view so what is the possibility if i take another view on the main view it will give the right result – Ahmed Sahib Feb 06 '17 at 10:40
  • @AhmedSahib the issue is fixed now if you update Xcode to any version >= 8.1 so no need to worry – mojuba Feb 06 '17 at 11:50
1

Solved by unchecking "Auto Resize Subviews" to ScrollView

enter image description here

NSNoob
  • 5,548
  • 6
  • 41
  • 54
Thippi
  • 99
  • 9
0

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.

Community
  • 1
  • 1
Michael Long
  • 1,046
  • 8
  • 15
0

Apple just came out with XCode 8.2, which fixes this problem for me. I have been using XCode 7.3.1 for my interface design parallel to 8.1, but I can now use 8.2 without any problems.

The storyboard gets updated with widths and height of frames though, to accommodate the new 'View as:' functionality. Though it doesn't seem to affect running on device/simulator.

Curiously, the bugfix it is not noted in the XCode 8.2 release notes.

Original answer here

Community
  • 1
  • 1
Thermometer
  • 2,567
  • 3
  • 20
  • 41