Questions tagged [adaptive-layout]

Adaptive Layout is a technique for supporting multiple display sizes and orientations in iOS applications.

Technical Overview

Adaptive Layout has been available since iOS 8. Instead of specific device types, or orientations, it introduces the concept of Size Classes. A size class can be either Compact or Regular in Horizontal or Vertical directions. Additionally there is an Any size class which serves for general layout constraints.

Some examples:

  • Compact Width + Regular Height represents an iPhone in portrait orientation.
  • Any Width + Compact Height will apply to iPhones in landscape.

Each size class may have its custom layout, with its own set of constraints. Adaptive Layout uses a hierarchical approach to determine which rules to use:

  • Any rules are used for general use: If there are no specific rules in either Horizontal or Vertical layouts, the screen will show according to these constraints. This is the perfect place for defining shared layout rules
  • Use Regular or Compact to achieve custom layout rules for a specific subset of Size classes. For example, to achieve a speficic layout for iPhones in landscale mode, proper constraints must be installed in the Any Width + Compact Height size class.

To support this new approach UIKit was also extended with Trait Collections. A UITraitCollection object describes the properties of an user interface element, such as its display scale (Retina or Non-Retina resolutions), device idiom (iPhone or iPad) and its size class.

In case of any change in layout (e.g.: a rotation), developers can examine the new traits, and act accordingly. In order to support this new approach, previous rotation-focused methods have been deprecated in favor of handling transitions between different trait collections.

Where to start?

106 questions
0
votes
1 answer

Higher Constraint Multiplier for Larger iPhones in Adaptive Layout

I'm defining a constraint as a multiplier in from the left margin as below: This looks fine on the 4 inch iPhone, but on the larger iPhones it is a little off to the left. Is there any way I can account for this? As far as I'm aware none of the…
Chris Byatt
  • 3,689
  • 3
  • 34
  • 61
0
votes
1 answer

Spacing layout elements with adaptive layout from iPhone 4s to iPhone 6+

I'm attempting to build a view (iPhone only, portrait view only) using adaptive layout. It should all be on a single screen (ideally no scrolling). I've managed to get it working (reasonably) for the iPhone 5 - 6+. However, my issue comes with the…
shoesole
  • 105
  • 5
0
votes
2 answers

IOS AdaptiveView Popover and NavigationController: how do they work?

I am updating an old app to the new adaptive size way of doing things and having difficulty getting a popover with a navigation controller to work. My goal: I want to be able to open a popover from a button when the app is either compact and…
johnz
  • 489
  • 2
  • 17
0
votes
2 answers

Using adaptive layout to move text fields when switching between portrait and landscape

I am trying to build a simple user form which is adaptive to the screen. Right now I am able to show some text fields vertically. I want to group two fields together so that they will appear next to each other horizontally in the landscape mode. How…
Himanshu Yadav
  • 13,315
  • 46
  • 162
  • 291
0
votes
2 answers

How To Design an UI to support all the screens of iPhones and iPads

I am working on a project in which I have to support all the iPhones screens like (iPhone4, iPhone 4S, iPhone 5S, iPhone 6, iPhone 6+) and iPads(iPad Mini, iPad Air, iPad Air 2, iPad 4, etc). I was in a thought of using AutoLayout and…
0
votes
1 answer

Unique multiline UILabel looks using auto layout

I have a multiline UILabel that I'd like to look similar on different devices (iPhone only). If it was a single line, I'd simply place the auto layout constraints and enable Autoshrink and set the Minimum Font Scale. The height of the label is…
Darius41
  • 3
  • 2
0
votes
2 answers

Unable to calculate row height using constraints if size classes are enabled in project?

I my application i have to count cell height dynamically and i support iOS7 and iOS8 for my app. I'm following Ray wenderlich tutorial for this purpose. After spending a whole day on this i came to know that this technique only works if size classes…
Blios
  • 719
  • 1
  • 16
  • 30
0
votes
1 answer

Adaptive Layout - calculate second row of views based on view width

I am programmatically adding a dynamic number of UIButton which are labeled as hashtags to a compact view using Adaptive Layout. Is there a way for adaptive layout to automatically calculate when the width of the view is met and a new line is…
Oh Danny Boy
  • 4,857
  • 8
  • 56
  • 88
0
votes
1 answer

How can I keep things aligned in an adaptive layout

I'm building an adaptive design using CSS and I'm wondering how I can keep things nicely aligned. Two examples so far: my page: http://www.spabc.com/drupal/ now, I would like to keep the check-rates_btn aligned with the titleimg as the browser…
stdcerr
  • 13,725
  • 25
  • 71
  • 128
0
votes
2 answers

Migrating an existing app to support Adaptive Layout

I have read blogs about Adaptive Layout and I have done some tutorials to see it in practice. I now want to try to migrate an existing iOS app to support Adaptive Layout / Size Classes. On the internet there is a lot to read about Adaptive Layout on…
Brabbeldas
  • 1,939
  • 4
  • 20
  • 32
0
votes
2 answers

iOS - Adaptive layout (Size classes) Fetch Data as early as possible, one time and place a UIView in viewcontrollers views center

Im using Auto layout with Size classes enabled. I want to fetch data as soon as possible and it works fine doing this in: override func viewDidLoad() { super.viewDidLoad() fetchData() } The problem is that the frame is not yet calculated…
user023
  • 1,450
  • 2
  • 17
  • 21
0
votes
0 answers

Adaptive Layout 3.5 inch iPhone

I'm really new to the adaptive layout scene. I'm working on a project that I want to look really great on all iPhone screen sizes. The question I have is: Is it possible to place a text box in a specific spot on each screen? The specific situation…
bnjmn.myers
  • 409
  • 2
  • 6
  • 15
0
votes
0 answers

Adaptative layout iOS 8 and iOS 7

I've to develop an app that should work on iOS 7 and iOS 8 devices. I'm using Xcode 6 to develop it and I'm having issue to design the UI. I designed the UI by using the adaptive layout, so when I try to run the app on a device in which it's…
lucgian841
  • 1,830
  • 5
  • 34
  • 57
0
votes
1 answer

how to make uilabel in uitableviewcell wrap relative to device based on adaptive layout and storyboards

I have the following UITableViewController in my storyboard: When I run in the simulator, it cuts off the paragraph in the bottom uilabel and looks like this: How can I get the label to stay inside the uitableviewcell based on adaptive layout and…
Atma
  • 29,141
  • 56
  • 198
  • 299
-2
votes
1 answer

Bootstrap 5 how to set breakpoints on rows

need make adaptation for the diagram in the screenshot below using Bootstrap 5 for mobile screens