I have made two storyboards: one for iPhone and another for iPad. To create the iPad storyboard I have used size class wRegular hRegular. After fixing all my constraint issues, it works perfectly in preview, but when I restart Xcode some constraints are misplaced.
Screen shot misplaced constraint while restart xcode
Screen shot after updating the frame
just a suggestion , if you are using the same UI for both iPad and iPhone , better to use a single storyboard for both .
The Basic concept of using Size class is whatever your Base design.it
should be designed in wAny hAny.
Now it you want any perticular view should be displayed in perticular
size class then only it can be added to that size class eg. if you
want label should be displayed in iPad then you should add it
wRegular hRegular Size class.As label added to wRegular hRegular it will only visible for iPad 7 not visible in iPhones.
So what you need to do is Redesign your StoryBoard in wAny hAny and
add constraints to it.
You can Also refer my answer which has some description Main.Storyboard Frames Not Updated
Related
I designed lots of constraints for my iOS app. Now the app works properly on all iPhone in portrait mode. I designed the constraints for the xCompact hRegular class. I realized, unfortunately only now, that all those constraints would be perfect also for all iPad in portrait. So, how can I change the constraints target class without recreating all of them for the more generic wAny hAny class? Thank you.
Select a constraint. In the last property in the attributes inspector, XCode shows you a list of check boxes with the size classes for which the constraint is active. The first check box represents wAny hAny, select it and repeat this for each constraint.
I've made my storyboard support only w:Regular h:Compact.
Cause i needed to support all devices in landscape.
But I've figure that it's not supporting iPad that way.
When i run iPad it just a blank page.
I tried to convert it to any:any but it hide all the sub views.
Is there anyway to convert this class size to any:any to support all without risking redo all this work?
Or at least I need a way to make it only for iPad?
First of all, wRegular hCompact is for iPhone 6 Plus in landscape, not iPads in landscape:
Be sure to check the description at the bottom of the size class choice.
If you want to convert existing elements to show in wAny hAny, try choosing each element, then going to the attributes inspector and clicking the + button at the bottom, then add it for any width and any height. Make sure the checkmark is there beside installed for any width and any height also.
I'm developing for both iOS7 and 8 iPhone.
Since iOS7 doesn't support compact-height size classes, I thought the consensus way to go about this was to use the any-any size class for landscape iPhone layouts,
and use portrait compact-width regular-height (cWrH) size class for portrait iPhone layouts.
I set a constraint on a view in any-any, then modify a constraint constant in cWrH to be specific to that size class. However, iOS7 device as well as Xcode preview ignores the any-any constraint, and uses the cWrH constraint for both portrait and landscape orientations.
I have no clue why this is happening. All I want to do is set different constraints depending on orientation.
This is easily replicated using latest Xcode 6.0.1.
Semi-related: How can Xcode 6 adaptive UIs be backwards-compatible with iOS 7 and iOS 6?
Screenshots below:
As per your question what you did is you have given leading,Top,height and width constraints in Any-Any Size Class.
So now its position will be fixed for any devices in landscape and portrait.
Now when you changes size class to compact width and make changes in top constraints it will affect both portrait and landscape.
What you need to do using size class with Any-Any to place your controls in View controller and set those constraints which you would like to keep in both portrait and landscape.
e.g.: If you want to keep height and width fixed give those constraints in Any-Any Size Class.
Setting constraints in Any-Any Size Class will keep those constraints similar for both portrait and landscape.
1.) Setting leading and top constraints in portrait you can use width- Compact, height-Regular.
2.) Setting leading and top constraints in landscape you can use width- Any,height-Compact.
Visit link below it has the great explanation and your most of issues related to auto layout using size class will be solved:
http://mathewsanders.com/designing-adaptive-layouts-for-iphone-6-plus/
Hope this solves you problem.
I am not sure how this happened but the view hierarchy on my Xcode6 project have 'hidden' themselves.
On the menu on the left the views have a weird icon and on the layout view and on the app itself the views do not appear.
On the right side all the constraints are greyed out.
Is this a feature or a bug? i can't really find anything i can click to get them to show again. Did i accidentally hit a shortcut?
I think you have changed the size class in the Xcode. May be you have designed it in one size class(not in wAny hAny)and accidentally changed to another. Only the layout designed in wAny hAny will be available for all devices/orientations. If you chosen any specific size class, your view's and constraint's will be hidden for other layouts(grey out). To get it back change size class at the bottom of the IB to yours(i don't know which one you have chosen initially). I would suggest you to design your layout in wAny hAny and do any specific layout changes for a device/orientation using other size classes.
change it here wAny hAny (Interface builder bottom)
I have a scroll view in a storyboard and the app is to run on iPhone4s and iPhone5s with iOS5 and iOS6.
I initially created the storyboard and was running on an iPhone5 and now I'm testing with an iPhone4.
Isn't there a way of just using a single storyboard for both the iPhone4 and iPhone5 and the when views etc. will automatically resize themselves depending upon the device, or do I have to use two separate storyboards?
I've tried numerous things, such as changing the simulated metrics size and many others but I can't find anyway of the view changing its size automatically - as I created the storyboard initially for an iPhone 5 the view now seems stuck at a 548 height when loaded. SUrely there must be a way of specifying in the storyboard that its height comes from the device? (Its height is the full screen less the status screen).
Further details
There is UIScrollView inside a UIView, the UIView will resize, the UIScrollView will not:
Yes, you can do it in the "Size Inspector", inside the Utilities menu. There you can set the autosizing and origin of any visible element.
This works in iOS 5 and 6 and it's not required to use the Autolayout, which is only for iOS 6.
Size inspector:
Second screenshot:
You have to use two storyboards for iphone4 and iphone5. Then you can check the device size to load the .xib according to it.