Adaptive Layout in Xcode 7.0.1 - xcode

I have an app that displays properly in portrait view but truncates in landscape view:
From the research I have done it looks like I need to understand Size Classes and Adaptive Layout. However, I am only concerned with layout on iPhone 6, not across different devices (eg iPad).
Before jumping into Adaptive Layout and Size Classes, which seems quite a complex topic, I just wanted to ask if there is a simple way to make this app display properly in both portrait and landscape for iPhone 6.
Thanks in advance!

Yes, you can do it without size classes, but it requires a reasonable modification to your UI.
If you think about it then having a picker always visible makes no sense for you. Looking at your image I am puzzled as to which date is currently being adjusted.
What you want to do instead, is to make your picker appear after user clicks on one of the dates. You can make it slide up from the bottom. In addition, you can add a label above it which will clearly indicate which date the user is currently modifying. That label can be placed in the toolbar to make it easy to add "Done" and "Cancel" buttons to the left and to the right.
In my view it would make much more sense and would also solve your problem. The rest of the UI can be put in the scroll view if you don't have enough space on old devices (e.g. 3.5 inch iPhones)

Related

Autolayout needed if only support one orientation?

Is Autolayout needed to setup for any subview, if my application only support one orientation (e.g., landscape right), applied for all UIViewControllers?
Yes, of course in the case of using animation I agree. But for the normal case, do I need AutoLayout?
Note: I am using XCode7, Swift, ios9
Understanding Auto Layout
Auto Layout dynamically calculates the size and position of all the
views in your view hierarchy, based on constraints placed on those
views. For example, you can constrain a button so that it is
horizontally centered with an Image view and so that the button’s top
edge always remains 8 points below the image’s bottom. If the image
view’s size or position changes, the button’s position automatically
adjusts to match.
This constraint-based approach to design allows you to build user
interfaces that dynamically respond to both internal and external
changes.
Unless you are making an app for one specific screen size, you will want to
use Auto Layout.
Use cases:
You want to support different size classes.
You want to support different screen sizes.
The content displayed by the app changes.
The app supports internationalization.
The app supports Dynamic Type (iOS).
Most of these changes can occur at runtime, and they require a dynamic
response from your app. Others, like support for different screen
sizes, represent the app adapting to different environments. Even
through the screen size won’t typically change at runtime, creating an
adaptive interface lets your app run equally well on an iPhone 4S, an
iPhone 6 Plus, or even an iPad. Auto Layout is also a key component
for supporting Slide Over and Split Views on the iPad.
Auto layout is not required at all. Even for multiple orientations.
However, If you don't use it, you'll have to manage placement for all the different sized devices yourself. So you might as well use it.

Using size classes and autolayout in xcode 6

I'm looking for some help with the new storeyboards and size classes in xcode 6. I'm looking to build a fairly simple interface with a few labels and text field, however I'm having problems making this look correct for the different devices.
As you can see from the attached image iphone 6 picks up the constraints and size set for the iphone, which looks daft (forcing the label for Score, for example, closer to the left because of the constraint) and doesn't make use of the screen size. Is there no way in xcode to build a layout and have it proportionately adjust to the screen size? Buttons and labels increase in size by x amount?
I can build completely separately for ipad and iphone and was happy to do this in previous versions of xcode but this seems to be defeating the whole point of size classes, and even if I was to do this my problem is still the iphone 6 and 6 plus which would pick up the iphone layout and look ridiculous.
I'm tearing my hair out with this so would appreciate any help.
Maybe constraint the lower elements to the bottom of the screen rather than the top. Other than that I think you don't have many options.
You can change your layout for different views using compact and regular widths and heights. Click on wAnyhAny at the bottom of your screen. This will provide a grid view pop up, which lets you customize view for different screen sizes. As you select different boxes, the bottom will tell you what size the view applies to.
You can change four things in a size class:
1. The constant for a constraint
2. If a constraint is installed in the view hierarchy
3. If a view is installed in the view hierarchy
4. The font used for many types of views showing text
This means if you want a different label or constraint for your iPad view, you can add that constraint just for that view using size classes.

grow or shrink UIImageView frame to fit the entire iPhone screen via AutoLayout?

So I'm still getting accustomed to the world of Auto Layout in iOS 6 and it's been a fun (or in plain English -- tough) migration coming over from strings & struts.
I have a UIImageView that's the background for a game I'm working on. Here's what a regular 3.5" Retina Display looks like in Interface Builder:
but if I change the "Size" pop-up in the Simulated Metrics field for the content view to "Retina 4 Full Screen", here's what I see:
And you can see the ugly black bar appearing along the bottom edge of the simulated iPhone 5 screen. This same ugly black bar makes it over to the compiled app running in the iPhone 5 simulator.
Are there any attributes or constraints I can apply via Interface Builder to get the UIImageView's frame to size correctly for the appropriate iPhone device screen size?
Or do I have to enter in constraints via code? (ugh)
I've watched the three WWDC videos and if the engineers covered the topic of sizing a view to fit a parent, they must have glossed over it really fast because I've haven't yet found or heard a decent method to get both UIImageView and NSImageView to size correctly to their parent views under both the iOS and MacOS side.
From what you're showing here, I think that what you want to do is drag the image to meet the bottom of the superview so that it takes up all of the space you want. On the bottom right in the IB view you will see a small, grey pill-shaped set of 3 buttons. Click the center one (once you have your imageView selected). It's the one that looks a little like this: |--|. It will bring up a list of constraints. Once you have done that, select "Bottom Space to Superview". You should then be able to switch between phones and have the image resize automatically.

UI Like Youtube in Android (Tablet)

I've spent 2 hours looking for a solution. I need to make a design
like the Youtube UI (Tablet UI) where it shows a vertical scroll, but
in each row there are 4 videos (landscape view). I've tried to do
something similar, but i couldn't =(
Is there any place where i can get the source code of the youtube
application for Tablet? Or maybe some resource to solve this? :(
BTW, my try was designing UI with scrollView, LinearLayout and my_item.xml, i tried to inflate my_item.xml adding programmatically into the linearlayout (horizontal orientation), but it doesn't work in the way that i want. I need something like a linearlayout but with horizontal and vertical orientation at the same time (something like a div).
I was thinking to use a ListView and a custom adapter (with my_item.xml), but i'm not sure if this can be the best solution.
Thxs
You should create seperate resources for each layout.
For example if the user is in Portrait mode you would have the correct layout in.
layout-port: layout for portrait orientation
layout-land: layout for landscape orientation
Read more on providing alternative resources here
Also i would recommend to read more on Handling runtime changes
This will help you with recognizing when the user changes orientation. You could actually use this guide and when the user flips the devices orientation you could then change the layout. Keep in mind hard coding this can be dangerous though. I would recommend using the layout folders.
Good luck!
Finally i solve my problem.
It works with a linearLayout(vertical) and adding linearlayout(horizontal) for each row. And obviously managing my scrollview.
BTW, i still think android should have a layout like a "div".
Thxs all

Fluid or fixed layout

I am working on a data entry application and I am considering using a fluid layout approach ala Swing and Silverlight where the controls resize based on the window size. My question is simple: what feedback if any have you received from users on each of these approaches? Screen size aside, I will still have a vertical scroll in place so I am wondering if I would be best served to simply go the fixed route and absolute position/size content.
Do not go the fixed route. If the user resizes the window, they do so for a reason. The widgets should resize appropriately. I can think of no valid reason to ever use a fixed layout except in vey specialized circumstances.
That being said, don't have a layout where input fields wrap. That would be very disconcerting. Just let your widgets grow and shrink naturally.

Resources