Editor > Canvas > Live Autoresizing missing in Xcode 7? - ios

I am using old autosizing constraints and want to see live how it will behave like in old days but somehow I don't see this option anymore and it is not autoresizing view when I resize it in editor... So it is not possible anymore ?
Ok maybe I am not too clear... but thats because I thought this is so obvious and used a lot feature of xcode editor...
So I have this on my screen
Before when I dragged corner of view that has size freeform view resized and all view inside resized also according to autosizing layout constraint. Autolayout is disabled in xib. It was possible to turn it on or off in menu Editor > Canvas > Live Autoresizing.. Now there is no such option. Is it possible still somehow ?

So I cam back to my own unanswered question, just accidentally I found that live auto resizing(old style) in editor works, just little but differently. When you change size of view in Size inspector by those up and down buttons, it works like old days...

Related

How to scroll inside of UIScrollView in Xcode Storyboard Editor

I have a horizontally scrolling UIScrollView that runs "off" the screen. See image:
I want to be able to edit the content more directly in the Storyboard rather than guessing where to put Views etc. As you see in the image above, you can't see the entire text of the UILabel, nor the ImageView at the end, much less anything else I might want to put there.
I'm using Xcode 14.2.
I answered this ten years ago, and in a perhaps better way a few months after, but due to the endless vicissitude of Apple's designs, the procedure has become slightly different, so here's a new answer.
You can't scroll a scroll view in the storyboard editor. As a workaround, you can make the scene wider, and the scroll view wider, so that you can see all of its content in the storyboard editor.
Select the view controller in the storyboard outline.
Open the Size inspector. Change the setting for “Simulated Size” from “Fixed” to “Freeform”.
Increase the width of the simulated size as needed so that you can make your scroll view wide enough to see all its content. Depending on how your constraints (or autoresizing mask) are set up, the scroll view may get wider automatically.

how to use a xib file for all device sizes in xcode

I would really appreciate if someone can tell me about how can I use one xib file to target different device sizes. I am creating a Custom Keyboard extension using a xib file having view property of "freedom". The view loads great in iPhone 4,4s,5 and 5s. However whenever i run the app for iPhone6 or 6s there is a blank space at the right hand side. (please see the attached screenshot, missing area is shown in red), looks like the keyboard doesn't stretch according to the screen size.
How can i fix that? I disabled the auto layout and use size classed option. I am a very new developer and coding using swift.
Thanks a lot
I would use autolayout for this, I would not disable it in the xib. Its also the reason as to why you have a space at the end of your view, as it is not expanding automatically to the sides, it has been set statically e.g. setting the frame.
I would have a look at this link but in the mean time I would re-enable autolayout then with your keyboard view container ctrl click drag to your main view and select Leading(left), Trailing(right), Top & Bottom Space to Container. Below is the popup menu from ctrl clicking then select the triangle at the bottom right then Update Frames, this will relayout the view. It might not layout the keyboard keys correctly but its is a start.

Xcode 6 view controller showing blank screen with autolayout

I'm trying to use view controller that I decided to use auto layout for. Before I used auto layout, the view showed normally like how I intended it to during runtime. But I decided to switch to auto layout (because after all, bigger iPhones are coming), and even after setting it up, getting no issues at all, and seeing that the app scaled well to the iPhone size in IB; I still have a blank screen. To prove it, here are pictures:
So why is this happening? I added the constraints in the square view, and it gracefully scaled to the iPhone view in Interface Builder. If you also look at the sidebar, the alerts for auto layout errors are not present. And IB is rendering everything. But why is the simulator blank?
And yes, I connected all the elements to be code correctly. I verified. And yes, I have code that puts text in a label. Here it is, in the 'viewDidLoad()' method:
override func viewDidLoad() {
super.viewDidLoad()
self.titleLabel.text = "Hello, World!"
}
And I will reemphasise: the app worked before I did auto layout. For this build, I deleted all the elements, relocated them, reconnected them, and added tweaked the view with auto layout unit IB rendered it correctly. But I'm getting different results here.
Please help me. Oh, and sorry for the massive images, I can't figure out how to shrink them.
EDIT: I've gone through and used the view debugger, and tried to capture the view hierarchy to look for clipping or occlusion. Funny enough, the view debugger shows the content properly, and there wasn't any clipping or occlusion that I saw. When I tried to show frames in the simulator though, it didn't show anything. I'm starting to think that this is a simulator bug. Currently, I'm using Xcode 6 beta 6.
I recreated the issue by adding a collection view to a standard view controller and this seems to be the problem:
Having Xcode add suggested constraints gives you this, which causes the view to not show up.
It is aligning the view's left and right to the layout guides (which doesn't seem to be right)
You will have to manually add spacing constraints to your view.
This is what you want:
Try turning on the assistant editor and use Preview while tweaking your constraints.
(source: mattknott.com)
Do your Editing in "wAny hAny For All Layouts Base values" mode. then you will not see blank screen while testing on different devices.
Mode selection can be one from bottom bar.
Good Luck

Xcode 6 Storyboard the wrong size?

Built a new project from scratch in Swift in Xcode 6 (Beta 1) and have seen some strange behaviour with Storyboards and the output that I am viewing.
I have built a simple interface (as shown below) - with properties of View Controller included.
When I run this in the simulator I would expect 'Hello, World' to be central in the user interface - however it seems that this 'Square' is simply being fit into the iPhone screen and thus the wrong view is being shown (see below).
My question is: has anyone else seen this behaviour and how did they fix it?
Thanks!
Do the following steps to resolve the issue
In Storyboard, select any view, then go to the File inspector. Uncheck the "Use Size Classes", you will ask to keep size class data for: iPhone/iPad. And then Click the "Disable Size Classes" button.
Doing this will make the storyboard's view size with selected device.
While Asif Bilal's answer is a simpler solution that doesn't involve Size Classes (which were introduced in iOS 8.) it is strongly recommended you to get used to size classes as they are the future, and you will eventually jump in anyway at some point."
You probably haven't added the layout constraints.
Select your label, tap the layout constraints button on the bottom:
On that menu add width and height (it should NOT be the same as mine) by checking their checkbox and click add constraints. Then Control-drag your label to your main view, and then when you de-click, you should have the options to center horizontally and vertically in container. Add both, and you should be set up.
If you are using Xcode 6 and designing for iOS 8, none of these solutions are correct. To get your iPhone-only views to be sized correctly, don't turn off size classes, don't turn off inferred metrics, and don't set constraints (yet). Instead, use the size class control, which is an easy to miss text button at the bottom of Interface Builder that initially reads "wAny hAny".
Click the button, and choose Compact Width, Regular Height. This resize your views and cover all iPhone portrait orientations.
Apple's docs here: https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/SelectingASizeClass.html or search on "Selecting a Size Class in Interface Builder"
In Storyboard, select your ViewController and go to Atribute Inspector. At the very top, under Simulated Metrics you have Size and Orientation properties which are set to Inferred. Change them to desired values.
In order for an application to display properly on another screen size, you also have to setup constraints, as described by Can Poyrazoğlu in the first post.
I had this issue in xcode 6 and there is a way to resolve the resize conflicts. If you select your view, at the bottom you will see an icon that looks like |-Δ-|. If you click on it, you're project will resize for different devices.
Go to Attributes Inspector(right top corner) In the Simulated Metrics, which has Size, Orientation, Status Bar, Top Bar, Bottom Bar properties. For SIZE, change Inferred --> Freeform.
On your storyboard page, go to File Inspector and uncheck 'Use Size Classes'. This should shrink your view controller to regular IPhone size you were familiar with. Note that using 'size classes' will let you design your project across many devices. Once you uncheck this the Xcode will give you a warning dialogue as follows. This should be self-explainatory.
"Disabling size classes will limit this document to storing data for a single device family. The data for the size class best representing the targeted device will be retained, and all other data will be removed. In addition, segues will be converted to their non-adaptive equivalents."
For anyone using XCode 7, it's very easy to design for a specific device size (instead of the default square-ish canvas).
In Interface Builder, select your ViewController or Scene from the left menu. Then under Show the Attributes Inspector, go to the Simulated Metrics, and pick the desired Size from the dropdown menu.
You shall probably use the "Resolve Auto Layout Issues" (bottom right - triangle icon in the storyboard view) to add/reset to suggested constraints (Xcode 6.0.1).

How to test behavior of Auto Layout constraints in xib without launching app?

I'd would like to see how the controls on my xib behave without actually launching the app.
In the Xcode documentation it says "[t]o test the behavior of Auto Layout constraints when you are editing a nib file, hold down the Command key and resize the window."
Does this only apply to OS X or is there a way to do it with an iOS app as well?
In xcode 5 you can preview how your view will look in different device screen and OS's. Open the assistant editor (Command+alt+enter) set it to preview and select the viewController you want to test. In the preview tab you can change screen size and iOS version.
What I have found to work is to switch your view controller under Properties -> Simulated Metrics -> Size to Freeform.
Your view should now be resizable with the mouse and the constraints will be in effect during resizing.
If you are designing full screen view, you cannot scale it but you may apply retina 3.5-inch form factor to view it in different height.
If you are putting views in container like UIScrollView, you may rescale the container to see if subviews moving or resizing as designed.
It is powerful when you are designing stand-alone xib for cell or custom views.

Resources