Facing Autoresizing Issue - ios

1I am using Xcode 11 for this project which is fully used autoresizing. Now all screens become like this. Not getting what issue it is. It's working fine in Xcode 10.

1.Try adding constrain again and works.
If point 1 does not work.
you can also set height of the view by calculating the total height of your content.

Related

UITableViewAutomaticDimension not working on Xcode 11 and iOS 13 with trait variations

I have view in xib that registered to tableView and calculate height through UITableViewAutomaticDimension. And all worked fine before update to Xcode 11 and iOS 13, now height small and incorrect.
What I noticed, if I remove all constraints trait variations it appears to work again. But if I add at least one trait variation for constraints(no matter horizontal or vertical) As on this image
Even with two checks, it breaks. But such variation working good, not breaks layout
.
Maybe bug in Xcode or something. Has anyone encountered this problem?

XCode 8 XIB Autoresizing issue

I have older code, written for iOS 6. I need to implement it for iOS 10 with some new SDK. I have some XIB's. Everything was working perfectly when I was changing them. But in one XIB, when I try to change Image in my Interface Builder of UIImageView, whole layout just collapses. I have 2 views, called TopBar and Content. When I try to change just background image of TobBar View, Content view just collapses, actually, TableView in Content View just goes off the screen on the right and you can scroll to right to see content of a cell. Everything is shifting in my Content View to the right. In my XIB, image view is shifted, TableView is so big to the right. When I place everything as it was, sam thing is happening after build. I have been reading for some time now, and changing from XCode 8 to XCode 7.x in my IB does not work, layoutIfNeeded does not work. Does anyone knows what's the problem? Code still uses Autoresizing masks.
Anyone in same situation as me: in XCode 7 it is working. So, I draw in XCode 7, and build in XCode 8, but I need to build for like 8 times, when it fixes itself. I have reported a bug to Apple.

Autoresizing issue in Xcode 8

=== 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.
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.
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
Which means the whole UI design is messed up. This is weird.
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,
If we use also boundary autoresizingMask at that time not facing this issue. Like,
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.
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.
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.
Xcode 8 beta 2 solved this problem!! I already checkeded now!
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!
Solved by unchecking "Auto Resize Subviews" to ScrollView
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.
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.
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

Auto layout doesn't work on iPhone 6 device but works on emulator

I have an app which uses auto layout constraints added in Xcode designer , mostly using "add missing constraints" option from Editor menu , problem is screens looks good on iPhone 6 iOS 8.3 emulator but doesn't work on actual iPhone 6 device iOS 8 as well. I m not adding anything from code
Below are the examples
What am i missing with auto layout ?
**** additional details ***
There is a principle that you need to know.. Every view you add to the storyboard must have enough constraints to confirm it's:
Width
Height
X position
Y position
You should review the constrains you added.
Especially the first textfield(Your Full Name).
Seems like it's Y position constrains wrong.
You will get into problem 9 out of 10 times when Xcode adds missing constraints for you. I would suggest you to go for a better tutorial of autolayout.

In xcode 6.1, interface builder deleting ui elements

I have a view with some tableviews and some collection views and also some buttons and labels.
I'm not sure if this is new with Xcode 6.1 because I have not worked on the ui aspect of this project for some time. However, when I try to resize just about anything in the view, my tableviews and collection views, and possibly some other elements I am not noticing, get deleted. Specifically, it seems their frame or rect propertied get deleted.
To be clear, this only occurs when I attempt to resize the element by dragging the sides in interface builder. If I resize them by changing the numbers directly either in the IB sidebar or in the xml, this does not happen.
I'm wondering if this is a bug in Xcode or if I have done something to cause this behavior which I can change.
Thanks!
I acheived a fix, at least for this project by turning off auto layout in "show the file inspector" -> "interface builder document"
I have never used this feature in the past so I do not know if it was on in the past but I am wondering if the new Xcode version turns it on by default where the others left it off.
It may also be possible that it has always been on but there is a bug in the feature in the new version.
This fixed the issue for me, at least in this particular project and at least for now. I hope others find this useful.
From here it looks like a bug in Xcode 6.1.
I created a clean project and the behaviour is the same on my machine:
https://github.com/nasht/Xcode6ConstraintTest.git
Resizing one view makes others disappear. Changing a layout constraint from a = to <= or >= also seems to do it.
I've raised a bug with Apple. Suggest you do the same.
workaround: You can install xcode 6.01 and use interface builder from there. You can still compile and run your code using xcode 6.1 if you're relying on xcode 6.1 specific features. (you'll need to rename your xcode.app so you can run both instances. ) It's ugly, but it works.
I found that it's fixed on the next version of xcode (6.1.1)
same problem, yosemit and xocde 6.1. I can resize some view only if i disable autolayout.
I think I ran into this 'problem'. I believe this was because one of the constraints I had was not setup correctly.
What OS X Version are you on? I updated to Yosemite today and 6.1 along with it. When I would resize a label my other elements were not getting deleted but instead getting resized and repositioned. The width / height would change to 0,0 and the x / y would change to 0,0 as well.
I was noticing other issues with Yosemite so went ahead and did a time capsule restore back to Mavericks and Xcode 6.0
I had the same problem in universal app; iphone works fine and the ipad doesnt work.
I'm using xCode 6.1 and OSX Yosemite
My app supports iOS7 and iOS8 and i had the same problem on iOS7 on iPad version only
Fix:
So i fixed it by setting Simulated Metrics in interface builder by
Size = iPad Full Screen and Orientation by Landscape or Portrait
I have got the same kind of problem with Xcode 6.1 and Yosemite :
I have created a view that I have added to the main view, so it appears like a sub view in the View Controller Scene.
Then I resize this subview to 320 x 568. My program works. It corresponds to the program dropit of Stanford CS193P Lecture 9.
I save the project, close it and reopen it : the subview has its width and height set to 0 !
I tried to open the project dropit of Lecture 8 that is quite the same, which was working before (I think in Xcode 6) and same problem ! First I thought that tapping (related to the subview) was not working but found out that tapping was not working because I was tapping on a subview which has its width and height set to 0 !
I have reset the size class wCompact hAny to which all the UIElements are added. and got corrected.

Resources