TPMultiLayoutViewController iOS

* * * * (52 ratings)
TPMultiLayoutViewController | App Code for Sale | Hero
TPMultiLayoutViewController | App Code for Sale | Hero


A drop-in UIViewController subclass that automatically manages switching between different view layouts for portrait and landscape orientations, without the need to maintain view state across two different view hierarchies.

The Problem

  • You want to support portrait and landscape modes in your app.
  • Having just one view layout for both portrait and landscape doesn't give good results.

The Conventional Solution: Double Handling

  • Create two distinct view hierarchies: one for portrait and one for landscape.
  • On orientation change, set this.view to either your portrait view, or your landscape view.
  • On load, perform your initialisation on both views: Big Overhead.
  • Whenever your view/app state changes, sync the state across both views: Big Overhead.

An Easier Solution: Layout Templating

  • Create two distinct view hierarchies: one for portrait and one for landscape.
  • Extract just the layout information from the two view versions: use the original two view hierarchies as a layout template.
  • Maintain one single view hierarchy: no double handling, no state syncing.
  • On orientation change, simply apply the layout information we extracted to our single view hierarchy, to achieve the new layout.

In summary, we skip the double handling by keeping just one view, not two views we need to sync. When the orientation changes, we just rearrange the view, using the layout we extracted from our original two views.

0 Comments Leave a comment


Please login in order to leave a comment.

Newest first

to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.