App Development

Multitasking in iOS 9 for Developers and Designers

At this year’s WWDC, Apple announced a new and exciting user interface change for iPad with multitasking. With multitasking enabled, users will now be able to run more than one app side by side, greatly increasing the use of the iPad as a true productivity device. This also means that users are going to expect great multitasking experiences, and existing applications will need to adapt to this new paradigm to give users the best experience possible.

Multitasking Basics

There are three major types of multitasking support in iOS 9: slide over, split screen, and picture-in-picture (PiP). Slide over allows a user to swipe their finger from the right hand side of the screen to show a compact version of an application. Users can also swipe down from the top of the screen to choose which app is displayed in the slide overview. While the slide overview is open, the current primary application is dimmed and the user’s focus is directed at the app in the slide over pane. Split screen (only available on iPad Air 2), allows a user to run two apps simultaneously side-by-side. In this mode, both apps are available for use and a user can adjust the size of each window by dragging the divider between the apps. This mode is a productivity boon, allowing a user to run a mail and web client side by side, or browse the web, while also taking notes. Finally, there is picture-in-picture mode, which allows a media app to play its content in a window that floats above other applications. This is likely to be a very popular feature, as users can now watch the latest shows, while also browsing for more information about the series, or while getting other work done.

Getting ready for Multitasking

If your application already supports auto-layout and adaptivity, then good news, you’re almost completely ready to support multitasking. If not, then now is the time to begin supporting those features as they are core to the multitasking experience.

In order to support multitasking, the first thing you need to do is configure your Xcode project properly. The following 3 steps are necessary:

  1. Build with the iOS 9 SDK in Xcode 7
  2. Add a launch screen storyboard
  3. Support all orientations

Once these steps are completed, the app should then be updated to support both auto-layout and adaptivity with size classes. The first step is to update your views and layout to use auto-layout constraints. This is necessary as applications no longer have complete control over the size of their views. Auto-layout will allow your application to properly resize based on the available space. If you are only targeting iOS 9 and up, I strongly recommend utilizing the new UIStackView, as it handles a lot of the sizing logic for you automatically.

In addition to auto-layout, your application should also be updated to support size classes. This is important, as multitasking relies heavily on size class changes to update the applications in the various modes. For example, in slide over, the right-most app is displayed with a horizontal size class of ‘Compact’ and the primary app is presented in a ‘Regular’ size class. If the split slider is dragged to the center, then both apps are presented with a ‘Compact’ size class. Adjusting your views based on these changes is very important to providing a great multitasking experience.

Finally, it is important to note that you should no longer use the screen bounds to adjust the size of your application. Instead, you should use the UIWindow bounds, as that is the actual visible area for your application.

Responding to change

In order to adjust your views in your application, you will utilize the same UIViewController functions that were made available in iOS 8. Those are:

  • willTransitionToTraitCollection
  • traitCollectionDidChange
  • viewWillTransitionToSize

It is important to note that each one of these functions are not called every single time the view is resized.  For example, willTransitionToTraitCollection and traitCollectionDidChange are only called when the trait collection actually changes.  In multitasking, the following cases cause a trait collection change.

  • When the application is first presented
  • When you are the primary app and each application is expanded to fill half of the screen
  • During rotations
  • When you are the secondary app and you are resized to fill the whole screen

There are also cases where a view size changes.  The viewWillTransitionToSize function is called in the following cases:

  • On rotations
  • When running as the primary or secondary app and the view adjusts between half and half split and 3/4 and ¼ split.

As you can see, view size transitions and size class changes overlap, but you are not guaranteed that all 3 of the adaptivity callbacks are called in every instance.

Handling Limited Resources

Perhaps one of the most significant changes brought about by multitasking is the limitation of resources. You can no longer assume that your app is the only app running at any given time. Care should now be taken to examine the amount of resources you use. Make sure to also update your application to support freeing of resources when memory begins to be constrained. In addition, access to hardware resources are also limited. External displays and access to the camera for video are now only available to the primary (left-most) application and your application will need to be updated to account for this change.

Designing for Multitasking

In this new multitasking environment, it is now more important than ever to start thinking about your iOS designs in new ways. Below are a few tips on getting the most out of your design.

Unify your design

Many applications today have traditionally thought of the iPhone and iPad apps as two separate designs. In the new multitasking world, applications will now seamlessly transition between the traditional compact horizontal layout of the iPhone and the regular horizontal size class of the iPad. As a result, the apps with the best multitasking experience will be ones that have a smooth transition between these two size classes and do not have a jarring change of UI when going from compact to regular and vice-versa.

Support Flexibility

Design your apps to use the standard margins and layout guides suggested by Apple. These will provide the best layout based on the current layout and size of the views. In addition, begin using the new readability layout margins to provide the best width for readable content based on the current layout.

Design for input changes

Now that two applications are running side by side, it also means that there are cases where iOS may be displaying a keyboard that covers your content even if you are not in the application that requested the display of the keyboard. Evaluate your design to determine if there are UI elements that should adjust on the screen based on the keyboard hiding and showing, even if your app would not normally use the keyboard.

What if I don’t want to / can’t support multitasking

There are two reasons you might not want to support multitasking. If you are writing a game or if your app needs consistent access to the camera. If this is the case, or if you are not ready to support multitasking yet, just add the UIRequiresFullScreen key to your Info.plist file and set its value to true. This will opt-out of slide-over, split-screen, and PiP support for your application. It is important to note, however, that other apps will still be able to slide over your application or display PiP content over your application. So, you will still need to handle possible memory constraints.

Multitasking is a huge improvement to iPad productivity and will be heavily used when iOS 9 is released. By following the tips and guides above, you will be able to provide an excellent experience to your users.

Xcode Cloud: Choosing the Right Continuous Integration and Delivery Tool for Your Team

Apple recently announced the release of Xcode Cloud at the latest iteration of their...

Read the article