All Subviews got disabled in ViewController Scene - ios

I'm experiencing a weird problem in my storyboard. I can't found any of my subviews in my view controller (subviews of uiview) and at the same time all the them got disabled there in view controller scene. But if I run the project in simulator everything is working fine...

If you are using xcode 6.0, please update you xcode to the latest version as there was a bug in xcode 6.0 that whenever you resize a control in a viewController, all the controls of that viewController changes its height and width to 0. Meanwhile you can change you controls dimensions from the Size inspector in the right hand side rather that doing it by clicking and dragging the control to avoid this problem. I hope this helps you.

Related

Xcode storyboard - can't drag to make constraint, items disappear when switch between size classes

In my project I want the iPhone portrait version to stretch a view but the landscape and iPad version to have a specific width so it doesn't stretch since the iPad is wide and so is iPhone in landscape. The problem is, when I set one up, I switch to the other one and everything has disappeared. If I start dragging views from the left panel to the storyboard they appear again, but when I switch to the previous size class everything has disappeared on that one. I also can almost never drag on that ViewController's box to do what I want. For example, if I want to drag from a UIButton to the background of the layout it would normally bring up a menu with 'vertical spacing' etc but now it comes up with 'Outlets Delegate'.
How do I fix these issues? Nothing is working.
Solved it by deleting everything in the ViewController, re-adding everything in w-Any h-Any and adding specific constraints in the relevant size classes.

Storyboard preview issue after converting to Swift 3/Xcode 8

Something strange happened to my project after I upgraded to Xcode 8 and converted the project to Swift 3.
Most interesting thing is that layout shows fine in the simulator but in the Preview everything is shifted to the right. Center of all devices appears to be almost at the right edge. For example I drag a label to the storyboard select Align Horizontally and add a constraint to the top... in preview it shows up for all devices shifted to the right instead of in the middle but in the simulator label is in the middle, exactly where it is supposed to be.
Also, if I create a new ViewController is would work just fine in preview and simulator... Anybody knows what can cause this issue?
In Interface Builder, select the view controller and then choose "Update Frames" from the "Resolve Auto-Layout Issues" popover menu that is in the lower right corner of the Interface Builder canvas. The issue is that in Xcode 8, the size of the previewed scenes has changed. If you tell it to "Update Frames", the various subviews should be adjusted to reflect the new "simulated size" for the scene's top level view (assuming all of your constraints are properly defined).
Leaving Xcode and re-starting worked for me to get the correct view per device in Storyboard again.

Content inset not working Storyboard Xcode8

Recently I have updated Xcode 7.3 to 8. While opening the project the project settings also have been updated for new Xcode.
Now the insets given for a button image for positioning the image inside button frame is not working as in previous Xcode(7.3) version.
The image insets are given through storyboard. Image was used here to have large clickable area for button than the button image display area. Is there any other options to get it through storyboard.
In Xcode 8 the button content/title/image insets have moved to the Size Inspector tab:
Which seems quite logical by the way! 😀
I had this same problem and solved it with image insets and the Horizontal/Vertical Alignment controls. My problem was that I had the wrong alignment controls selected. Once I changed it my insets worked properly for what I was trying to accomplish.
I created a button with an image and the I wanted to shrink the image down to not fill up the entire button So I set the image to the UIButton image property in storyboard and then set the image insets to my liking
But it did not center my image with the inset of 5 on each side. The image would look like this and that was not what I wanted
If you change the horizontal/vertical alignment controls I was able to the button image to my desired look I wanted
tl;dr: Set the "Style" to "Default"
(if you're on Xcode 13, iOS 15 or later)
Long answer:
I know the very title of this question references Xcode 8 - but this comes up in a Google search and I had issues in Xcode 13 (iOS 15) where the content/title/image insets are not reflected in the storyboard or at runtime. This was due to the new button system, and the solution was to set the button's "Style" to "Default" (it was "Plain").
Its weird,but it actually works until you add collectionview or tableview in your Viewcontroller. Try setting the inset without having the scrollview or tableview in your view controller
There is a weird behavior when having a UITableView or UIScrollView on the scene (as mentioned by #RAHUL JOSHI). Sample
Solution: Just ignore the previsualization bug as on runtime this will work normally.
Content inset for button is working perfect in xcode 8 beta.
See below screenshot that i have taken from xcode8 beta.

XCode 7 and iOS 8 Auto Layout top constraint issue

I recently updated my XCode 6.3 to 7 and strange things started to happen with my auto layout constraints in the storyboard.
My app uses UITabBarController with three tabs. The initial tab has a UICollectionView with top constraint set to 44px from the top layout guide (there is a toolbar in the embedding UINavigationController.
When I run the app on iOS 7.1 (iPhone 4), everything looks fine. The collection view doesn't go bellow the toolbar. However in iOS 8.4 (iPhone 6) the collection view goes bellow the toolbar UNLESS I switch tabs and go back to the first one, where the collection view is positioned where it should be.
What I did:
Unchecked all "Extend edges under...." for every view controller in the chain
Set all simulated metrics for Status/Top/Bottom bars to "None" in every view controller in the chain
I had the idea to check for #available(iOS 8.0, *) and extend the constraint constant +20 pixels. But when I switch back to this tab, the collection view goes 20 pixels lower than where it should be.
So, I guess something happens to the view controllers when I switch tabs. What is it? Or is there any solution. I'm on a deadline and this is the only problem I have with my app.
p.s. I can provide source code and XCode screen shots if needed. But still, I think it's something more theoretical, than practical.
1) click on your UITabBarController in storyboard->identity inspector
2) uncheck "Adjust Scroll View Insets"
repeat for individual view controllers inside UITabBarController
Sometimes this happen also to me. I suggest replacing the top layout constraint with an height constraint equal to the view of the ViewController, this resolved my problem.

Second scene view controller constraints issue

I am working on an iOS project when I ran into this problem. When I add second scene view controller and add buttons in it, the buttons don't show up on the simulator in correct place. It is stuck up at the topmost left corner, I am not able to move it down. I tried applying constraints but they are not taking effect. Can someone please guide me? Attaching screenshots of storyboard and simulator
You have the choice to Update Your Frame or update your Constraints
You need to delete and remake new constraints. Right now your constraints are reflected in what is happening when you actually run the app, but when you move the view around in the storyboard, the constraints won't automatically update.
Click on each individual constraint and delete it before you create new constraints with different constants.
You Have to deselect the auto layout from the right side button menu.
Thanks guys for those wonderful answers. I was able to get around this issue yesterday, it is because of device orientation setting, the simulator was running in landscape mode setting, when I changed it to Portrait mode it started working. There is a setting available in bottom part of the view controller which sets the view options for different devices, I had accidentally set it to "wCompact hCompact", this setting will default the image to landscape image of storyboard on simulator. In the simulator though I was viewing it in Portrait mode. Attaching the screenshot with this setting.

Resources