What is Auto Layout - what does it do, and is it an iOS 5 feature?
Since the new iPhone 5 has a bigger screen, all the options on how to optimize your applications for it come down to Auto Layout.
Can you point me to some article about Auto Layout, and how I can adapt it with my project?
I recommend watching the WWDC 2012 session Introduction to Auto Layout for iOS and OS X.
Auto Layout is a new way to define dynamic GUIs. Before, we had autoresizing masks, that described how a subview will resize or move when its superview is resized. With Auto Layout you can do the same and also a lot more complicated GUIs quite easily.
https://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AutolayoutPG/Articles/Introduction.html
"If Auto Layout in iOS 6 turns out to be anything like Cocoa Auto Layout in Mac OSX 10.7, the Cocoa Auto Layout Guide, a publicly available document, may give you an idea of how it would work in Cocoa Touch.
The underlying engine used by Cocoa Touch is Cassowary, and it's also used in other toolkits, such as enaml. I recently wrote a brief overview of Cassowary, with a comparison between Cocoa Touch and enaml wherein I port a Cocoa Auto Layout example to Python and enaml."
From: https://stackoverflow.com/a/11129597/1648976
And the WWDC Session: https://developer.apple.com/videos/wwdc/2012/?id=202
iOS 6 is still under NDA. Hold out for a few more days. It is an iOS 6> feature. In case you have a developer account, you must be already able to learn about Auto Layout from the documentation or from the WWDC 2012 session videos.
"Autolayout" is used to adapt layout to different screen size,orientation and localisation.
In Autolayout we don't give input based on "x" and "y" coordinate (old style). Instead we define the layout using mathematical relationship between the elements in our view. We can define this relationship using constraints or individual elements or constraint between a set of elements. Once we redefine the layout using this relationship .Our app can adapt to different layout based not only on device size like 5 inch or 5.5 inch in iPhone, but orientation and localisation as well.
For further understanding you can visit:http://www.raywenderlich.com/83129/beginning-auto-layout-tutorial-swift-part-1
What is Auto Layout?
Auto Layout is a constraint-based layout system. It allows developers to create an adaptive interface that responds appropriately to changes in screen size and device orientation. Without using Auto Layout, it would be very hard for you to build an app that supports all screen sizes.
Why Auto Layout?
Auto Layout is a way that lets developers create user interface by defining relationships between elements. It provides a flexible and powerful system that describes how views and the UI controls relate to each other. By using Auto Layout, you can get an incredible control over layout, with a wide range of customization, and yield the perfect interface.
Auto Layout is compatible with many of Apple’s most exciting application programming interfaces (APIs), including animations, motion effects, and sprites.
Reference:
https://www.appcoda.com/introduction-auto-layout/
UIView Autolayout is a very interesting concept in iOS App development. Autolayout takes care of responsive design. iPhone comes with different screen sizes every time. With the help of Autolayouts, you do not have to create your App design each time. Autolayout takes care of responsive design.
This article on "Introduction to Autolayouts" will give you enough understanding about it.
best tutorial link for autolayout:
https://www.youtube.com/watch?v=ugqFWPsY_A0
https://www.youtube.com/watch?v=vzyd33Pv9kg
https://www.youtube.com/watch?v=Nl2iMF0yKW8
https://www.youtube.com/watch?v=Gl6DibzPYa4
https://www.youtube.com/watch?v=J10vzrTcswI
https://www.youtube.com/watch?v=izES1zQjRUU
Related
I just started making an app, and I have done a lot but I was not working with auto-layout. My whole app is in landscape mode, and I want it to work on all iPhone's. I now designed it for the iPhone 5, but when I open it on iPhone 6, there is a lot of whitespace. Is there a button to automatically resize everything? Or must I add auto layout and do every designing bit again?
Unfortunately you're probably going to have to layout everything again with auto-layout. A way to expedite your process would be converting the storyboard to auto-layout and then selecting "Reset to Suggested Constraints". You can access this option by pressing the small triangle icon in the bottom left.
Despite this, you probably will need to update a lot of the constraints manually. But this should give you a step in the right direction.
Have you tried Size Classes? Or Stack Views?
Size classes:
Apple documentation # https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Size-ClassSpecificLayout.html
Apple documentation on Stack Views #
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/LayoutUsingStackViews.html#//apple_ref/doc/uid/TP40010853-CH11-SW1
A good tutorial on "Stack Views":
https://www.raywenderlich.com/114552/uistackview-tutorial-introducing-stack-views
The app I'm currently working on has a huge number of views. Some are webviews and some normal UIViews, with a ton of subviews. Now that the iPhone 5 has come out, how can I most efficiently change the frame size of the entire app to support both 4-inch and 3.5 inch devices? I certainly could use a whole bunch of if-else statements and layout several frame sizes for each view, but what's the best, most efficient way this could be done?
Most efficient way is to use one of the provided layouting mechanisms:
Autoresizing – Each UIView has property autoresizingMask and by setting it to one or many values (using | operator) you tell the view how to behave when the size of its superview changes. Elementary options:
UIViewAutoresizingFlexible...
...Width
...Height
...LeftMargin
...RightMargin
...TopMargin
...BottomMargin
Auto Layout – New in iOS 6, it provides more complex (very complicated) mechanism of relations between view attributes. Basicaly it is a superset of autoresizing and there are some long docs for it. I don't recommend it to you.
We are currently in the process of evaluating Delphi XE2, and as you would expect I've started with FireMonkey as OS X and iOS development is of great interest. I've seen a couple of walkthrough's where people have created iOS apps using XE2 and I've managed to do the same, however the bread and butter of 'business applications' on an iPhone (which is how iOS support is being marketed) are buttons, lists, grids and connectivity (REST?).
Anyway, once you've created your iOS HD project the TButton initially looks green, whereas the TSpeedButton and TToolbar looks exactly like it should (blue gradient). The TToolbar doesnt have any way of adding buttons, presumably this is just a Panel, then?
Has anyone created styles for FM iOS HD apps, or do any of the wrappers allow direct creation of the standard iPhone controls?
I apologise if that sounds a little backwards given that I am attempting to evaluate using the trial version (which among other things doesnt provide the source, for obvious reasons!).
Thanks,
Ross
FireMonkey does not have standard iOS or OS X components. It draws all the components on its own, using a complicated set of layered sub-components, which are all editable with the FMX style editor in the IDE (or with a text editor outside the IDE).
So you can mimic the iOS or OS X components with the styles you get with the product or with your own custom styles. But to use the original UIKit/Cocoa Touch components, you'll have to use the FreePascal translations and conversions of the original Apple headers, and not FMX.
There is no designer for such UIs, unless you want to use Xcode 4.x. I don't know if FreePascal can load and use .xib files, though (although, why not? Probably just not automatically). You can, of course, create and place such components in code, at runtime.
So you either:
use FMX and design your own styles or modify the existing styles to your need, or
use Xcode and .xib files. Not sure how to do that with FreePascal.
FWIW, you can place any FMX component on any other FMX component (e.g. also a textbox on a button on an arcdial on a list item in a listbox), so it should be possible to place buttons on a toolbar. You probably have to take care of their alignment and arrangement, though, and probably also for their behaviour. Use a TLayout, Padding, Margins and alignment for that.
What options do I have when creating menu with options (contextual menus). What is allowed and what does Apple provide?
I have a toolbar with buttons and a click of a button opens a menu with options:
Examples:
UIPopoverControllers are only available on iPads, but it's ok to create similar looking things for iPhone
What you see in the picture, is entirely custom. a UIView subclass likely. There are pretty much no limits to what you do with your UI, within reason, so no ugly highly contrasting primary/secondary colours, and it's best to keep it at least similar to the native UI. If you say use a windows 7 phone ui style in an iPhone app it's more likely to get rejected by Apple, than keeping to the style of iOS.
So make it look as "professional" as possible, using gradients and shadows, edge arrows, like in the above picture.
Apple provides pretty much nothing that your looking for,
Similar built-in widgets would be UIPopoverController (iPad-only) or UIActionSheet. I like your menu better though.
I would also recommend looking at the guidelines for such custom UI elements. I can not say what is 'allowed', but Apple is not shy about how your app should look/feel/function.
Towards the top of this link talks about toolbars, status bars, etc.
http://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW1
I have this setup in an iPhone app:
There is always a MKMapView on screen & a additional UI layer on top. The upper UI layer is managed by a simple state system. Each state is a UIViewController and has a .nib attached to it containing the layout.
I'm very new to Android development. What is the best way to build this on Android?
So far I see two options:
1. Have a single Activity & insert/remove layouts as the states change.
2. Have multiple Activities and have a layout for each. Is there then a way to keep a single MapView around beneath, without having one per activity?
Thanks.
In general, it is easier to have multiple activities, each with their own layout.
Before you get to far, make sure you read through the basic Android documentation and UI guidelines. Android has some UI paradigms that are a little bit different from the iPhone, so you generally don't want to just copy over exactly what you have.