Check if iPad supports multitasking in iOS 9 - programmatically

For iPad Air 2 or iPad mini 4, we can use all three different multitasking features (Split View, Slide over, and Picture in Picture). For iPad Air, iPad mini 2 or iPad mini 3 we can use Slide Over and Picture in Picture. Is there a way to detect these devices from code? For example, using respondsToSelector:someMultitaskingmethod ?

+5
source share
1 answer

Device compatibility

If you really want to make sure that your device has a certain compatibility, you can check the settings on the device compatibility list . This will show a series of keys that you can add to your application plan, which will additionally limit it to devices that support the required functions. Along with checking for the available classes mentioned below, I consider it a good matrix for what you want to accomplish.

A quick overview of the WWDC video , which describes the features you want to support, indicates that you will need to check out the iPad, iPad, iPad Air2, iPad mini 2 and 3. You can take a look at the screen sizes combined with idioms and class availability to ensure targeting only the right devices. IOSRES has a good matrix of these screen sizes, accessed by UIScreen.mainScreen() .

Another option is to examine TraitCollection to determine the correct device models / capabilities. These include properties such as displayScale and forceTouchCapability. You can even build your own collection of attributes to further describe your unique environment.

Basic approach

Testing only on devices is probably not what you want to do. Instead, you should check out the features available on the iOS platform, and some combination of a collection of idioms / device attributes. Then you can compare if this method is available using the response to the selector.

Check the updated SDK or Frameworks for more information about the picture in the picture (basically, the new methods do all the work and tell you if the device will support this function). Another precursor to running methods is to determine whether new classes can be created.

sdk

You can also explore options for testing specific equipment on the platform. See this example from Apple.

If you know that the targeted features are available at certain platform levels, you can check the version number of the operating system ( Apple Example ).

 + (BOOL)isURLLoadingAvailable { return (NSFoundationVersionNumber >= 462.6); } 

This article shows how you can support multiple OS and devices in detail.

Testing example for an accessible class:

 if ([AVPictureInPictureController class]) { //Safe to use AVPictureInPictureController } else { //Fail gracefully } 

An example of testing an available method:

 if ([self.image respondsToSelector:@selector(resizableImageWithCapInsets:resizingMode:)]) { //Safe to use this way of creating resizable images } else { //Fail gracefully } 

Acceptance of multitasking, separate viewing and slide

Apple details specific on how to adopt new behavior. They require tuning plists and other requirements above and above checking classes and other programming methods above. There is a good example of how to use Slide Over and Split View, download the Lister project (for watchOS, iOS and OS X) . For a sample with a picture in a picture, see AVFoundationPiPPlayer . AdaptivePhotos sample includes multitasking with iPad.

+6
source

Source: https://habr.com/ru/post/1235935/


All Articles