Nib view in Xcode Interface builder does not apply autolayout constraints - ios

I have a Nib view that my coworker has created with working autolayout constraints. When he resizes the view in interface builder the constraints are applied and the view is shown correctly.
When I do the same thing on my computer the constraints are not applied. We have compared the settings and view options but we can't see any differences.

The feature is called "live autoresizing" and its failure may be a bug. See this question where other people had a similar problem. In fact, just now it was working for me, but when I turned it off and on again in the Editor menu, it no longer did, even after restarting.
Setting up a keyboard shortcut for Update Frames in the Xcode preferences -> key bindings could help speed things up a lot. In my case I found it listed twice and one of them had a shortcut already assigned, but it didn't work. Ah, Xcode.
You can go to bugreport.apple.com and file a radar, but if you're going to do that see this page first.

Check if use autolayout and use size classes is enabled in the file inpector in the .xib file.

Related

I have to update frame of everything in storyboard every time I start Xcode

So each time I open my project in Xcode, I have 100's of warning because the frames of every UI Object has been moved. I have to take the time and go to each UIViewController and update frames on it.
Is there a reason this happens? How can I fix this? Any other information I need to mention?.
Do you use a repository for your code? There may be some configuration file missing, probably not comited properly
In my case, this was happening because size-class for which I have set the constraints and layout got changed when I opens the Xcode project. So make sure that the size class remain the same for which you have applied the layout or change it if it has been modified by the Xcode.
If above does not work for you, you can try having a local repository created by the Xcode and commit the code before you quit the Xcode.
Hope this helps!!
I believe this was asked previously here:
Interface Builder degrades storyboards, resizes and repositions views in small increments
I have not yet seen a fix to the problem, but the answer I posted there likely holds true here.
https://stackoverflow.com/a/28577800/682574
At least one source is due to storyboards resolving layouts to either full pixel boundaries (x=7.0, y=10.0) or partial boundaries (x=7.5, y=10.5). As best I can tell, this can be recalculated any time you view the storyboard and the rounding is actually determined based on the current display environment.
You can intentionally cause this behavior by viewing the storyboard on a retina display and then viewing it on a non-retina display. With my dual-monitor display, if I just drag a storyboard from one screen (retina 5k) to another (non-retina) it will generate a flood of misaligned constraints. Unfortunately moving it back doesn't fix them! Try it out for yourself (or don't ... it's a pain to correct).
In a team environment its easy to see how this could happen as soon as two people with different setups view the same storyboard.
How to fix it? I haven't heard of a workflow that properly corrects or avoids the problem unfortunately.
Here are a couple of reasons I've seen for intermittently misplaced views. I'm not sure if either of these is responsible for the problem you're seeing -- usually these will cause a few views to be misplaced here and there, not every view in your storyboard. But I've listed them just in case it helps.
Different team members may be using different versions of Xcode, which may position certain views slightly differently, and which will certainly change the storyboard file "tool version" and so forth.
Constraints are not usually happy with fractional widths/heights in them. This can be difficult to detect -- for example, you may have a view whose intrinsic height is an odd number of pixels vertically centered within a view whose height is an even number of pixels, causing the inner view to start at a half-pixel offset and want to be repositioned lower or higher when the storyboard is re-opened.
For xib files, you can easily write a script that updates automatically the frames:
ibtool input.xib --update-frames --write input.xib
But, you should not worry about these warnings: the frames will be automatically adjusted during the execution.
Its could happens due to having 4k external display. Everybody in my team does not have this kind of problem, only me.
After opening Xcode tries to align logical points to physical pixels, so everything moves about 0.5 point.

XCode Storyboard Issue

I cant see the Labels, Button etc in the View or their constraints though the Labels and Button appears on the side of the storyboard. And when you run the program in the simulator you can see that they are there.
The project from my colleague who uses XCode 6.3.1 and I am using XCode 6.3.2
and he doesn't have this issue. When he updated his to to the same version I have he had the same problem; so he went back to the previous version 6.3.1.
Now the problem persisted on my device even when I removed the 6.3.2 and substitute it with 6.3.1
stackoverflow prevented me from uploading the images but I can send it by email to anyone to see the screen shots
I think I found the answer but yet the labels seems to be shifted out of the view. but the Answer is: This problem occurs when one of the users design the view controller using the compact or any other dimension other than Any X Any. to fix the problem, click in any of the objects created ( label, button..etc), and go the attribute inceptor, and scroll down to the bottom and you will find a check box with the word installed. there will probably be more than one. Look for the one that is not highlighted, and highlight it. This should fix the problem.
Another faster solution instead of going over each object you can deselect
Use Auto Layout
Use Size Classes
then select them again

Interface Builder Views not showing up

All of my view controllers suddenly had this bug. Nothing shows up in interface builder, but it works fine when I run it. This makes it so I can't edit my views in interface builder. Whats going on here? Xcode 6.1 GM ios 8.1 B1. Swift.
I assume you made your design in a size class other than wAny / hAny. Switch back to the size class you used for design and your controls will reappear.
This happens when you press Command+Delete, meant for removing objects from only certain size classes. If you just did it, you can undo it, but otherwise I looked around and I can't find a way to turn them back on. The only menu references to it are after you press Command+Delete to "Undo Turn Off", so it may be a bug right now unless theres an alternative way to turn the layers back on.
I believe Harrison is correct, the greyed out views on the left mean they have been deleted for a certain size class, try changing the size class and see if they are active in a different size class
Thank you all for the help. I had designed the views in regular regular and then changed it to any any unknowingly.
I also encountered similar problems.And I solve this problem by check install...
This because of size classes. May be you uninstall some constraints in wAny and hAny. You need to re-install these constraints. After that you are able to see your view again.

Strange bug with resizing of UI elements in xCode 5? Video is attached

link to a video with bug
I simply created a project in xCode. Then I added any UI element to a view. Then I tried to resize this item to left and to right. No code, Interface Builder was used only.
I have checked with some types of projects for iOS and with UILabel and UIButton. The result is the same: when I try to resize the item from the left then it moves the parent view/viewcontroller instead.
Uncheck "Siblings and Ancestors" under Resizing Behavior in Xcode 5 Storyboard.
Voila! As such, resizing your UI elements will not cause your view controllers to move.
You need to uncheck the "Siblings and Ancestors" in your .xib/.storyboard file. See below screenshot of how to toggle this behavior on and off:
As has been said before, you must uncheck the "Siblings and Ancestors" option under Resizing Behavior in the Xcode 5 Storyboard.
The specific purpose of this feature is to be able to resize large groups of objects all at once. For instance, lets say that you have a Table View and you resize one of the cells. In this case, it would seem petty, since you would just have to resize the Table View Controller, but it becomes extremely handy once you have layered objects such as that.
Sorry for the somewhat duplicate answer, but you did ask for an explanation of why a feature like that would be added.
Additionally I have found out that another computer with the same version of xCode works with the same copy of project normally.
I didn't know how to solve this problem without uninstalling of xCode.
So I uninstalled it using AppCleaner and installed it again.

Why does the iOS Simulator show only a blank view/window?

I'm new to iOS development. I used the Interface Builder to add text fields and buttons to my view. When I run the app, the iOS Simulator only shows an empty beige screen. What am I missing? The console doesn't show any error.
It is because you have not connected your view to your File's Owner.
To do this Right Click on the View, Control Click on the Oultlet of your View and drag it to the File Owner.
This shall solve your problem.
Cheers
I reckon it's because you have AutoLayout turned on in your storyboard, but haven't set any constraints.
Follow my instructions in the following article, to confirm if this is true.
AutoLayout problem
Basically, with XCode 6, if you have AutoLayout turned on, you must set constraints on every single control... otherwise your screens will look fine within XCode, but the controls in your screen could (and will) end up anywhere and in any size when the app is run.
It's like designing a beautiful webpage, then displaying it in an angry, drunk, disorientated browser.
XCode is really unintuitive, and unhelpful for beginners... but once you learn the rules of AutoLayout (along with its many quirks), it's reasonable useful.

Resources