IOS 9 Split-screen multitasking (multitasking)

Source: Internet
Author: User
Tags compact windows surface

Gold field (GitHub sample source code)

Multitasking (multitasking) is one of the most impressive core features of IOS9, before the jailbreak version of the user has used a similar plug-in, Microsoft's Sophie (Windows Surface) series also has split-screen multitasking features, Allows users to run 2 or more apps at the same time. Multi-tasking in IOS 9 currently supports three representations: temporary presence and interactive sliding overlay (Slide over), real split-screen operation of the split view of two apps, and in-picture pictures in other apps that can be played on video (pictured in Pic ture) mode.

In the website's multi-tasking development documentation, Apple has made it clear that the vast majority of apps should be adapted to Slide over and Split View. And the latest Xcode 7 Beta version of the new project, the default is to support multi-task Drip ~ Of course if your app only needs a full-screen experience (such as game class, or really do not want to maintain the update old project code J), you can add in the Info.plist Uirequiresfullscreen the item and set it to Yes to prohibit split-screen functionality. It is so simple ~ ~

Figure 1 APP settings

Currently, only some devices that support iOS 9 can use the multitasking feature, and the device that supports split view has only the best-performing ipad Air 2 (the new release device after &). There are more devices that support both sliding overlay and Pip mode, such as ipad Mini 2, ipad Mini 3, ipad Air, ipad Air 2, and more. This is also a good understanding, after all, mobile devices, or to consider the performance and user experience. Here we temporarily do not talk about the picture-in-picture mode (in fact, the project is temporarily useless to ~)

The Slide over feature is activated by default and allows users to bring up a hover view on the right side of the screen (on the left side of the screen in a right-to-left language environment) to view and interact with the secondary application. If you cannot slide out of the hover view, make sure that the Allow multiple apps with multi-task------, settings----is turned on.

Figure 2 Setting settings

There is a button near the middle of the screen outside the slide over area, and dragging this button will enter the Split view mode. In Split view mode, it is rendered as two parallel apps that users can view, resize, and interact with. The app on the left is the main app, the secondary app on the right, the secondary app being dragged to the far left, the primary app being the main one, and the original main app exiting the foreground. Split view currently supports three split-screen ratios, 1/2, 1/3, 2/3, respectively. I think that Split View is really multitasking, at least 2 apps that can run & operate in parallel, while slide over looks a bit fake and is an app that's covered in another app.

Figure 3 Split view mode

Figure 4 Split view mode

OK, now back to buckle butt process ~ ~

If you're creating a new project with Xcode 7, congratulations, follow the Apple recommended standard process and you'll be thankful. If you need to do the old project upgrade adaptation, and code in the coordinate positioning is dead, then please prepare a wet towel paper, you can wipe the Spit star side wipe the tears on the side of the adaptation, the thought of our PDF Reader series to do the adaptation, it felt the heart of,38 degree of warm summer is also cold said good, If you want to activate multiple tasks, you need to

    1. Configure a startup Xib as a startup page, such as Launchscreen.xib, to Uilaunchstoryboardname.
    2. The app supports all directions (uisupportedinterfaceorientations), uiinterfaceorientationportrait, Uiinterfaceorientationportraitupsidedown, Uiinterfaceorientationlandscaperight Uiinterfaceorientationlandscapeleft, all set up.
    3. Use automatic layout (auto layouts)
    4. Enjoy using the Adaptive UI, like Size class,dynamic type God horse, come on.

Info.plist:

<key>UILaunchStoryboardName</key>

<string> Launchscreen </string>

<key>UISupportedInterfaceOrientations</key>

<array>

<string>UIInterfaceOrientationPortrait</string>

<string>UIInterfaceOrientationPortraitUpsideDown</string>

<string>UIInterfaceOrientationLandscapeLeft</string>

<string>UIInterfaceOrientationLandscapeRight</string>

</array>

The size class here has a section to note that the ipad's horizontal and vertical size classes are always "Regular". As the split screen appears, these changes will occur. Shows that your app will encounter different size Classes after the user operates the ipad screen. It can be seen that in the vertical direction regardless of the horizontal screen is Regular layout, there are two Regular layout and Compact layout in the horizontally direction, so when doing interface adaptation, the size classes to be processed have w:regular h:regular and w:compact H:regular two kinds.

Figure 5 View split layout type

The most troublesome part of the IOS 9 split screen feature is the adaptive interface, which needs to be handled using auto layout and size classes. If your app is fully self-adapting to the UI, then the split-screen function is almost no more processing, with XCODE7 recompile. I wrote a iOS9 split screen demo, with Xib and pure code two ways to implement the adaptive UI, you can refer to the next. As for the project development with Xib or pure code, each has pros and cons, to see everyone's personal habits and project situation to choose. I'm quite in favor of what Tang Qi said in this article. Since most of our projects are co-developed, I seldom use xib/storyboard in my own project, considering the probability of code versioning conflicts and the problem of code reuse.

Here is a general introduction to the implementation of the Xib, the first Xib interface under the W:regular h:regular this sizeclass, and then drag and drop the control and add the appropriate constraints and layout, and then select W:compact h: Regular this sizeclass, add a new constraint and layout adjustment interface, so that the interface is self-adaptive, the effect of such as. The Sizeclass and AutoLayout treatments are not detailed here, so if you are not familiar with Sizeclass and AutoLayout, you can read this article.

Figure 6 Demo App interface design

Figure 7 Demo App interface design

With the code-handling interface Adaptive, we can get the current Sizeclass type based on the Traitcollection property of the current UIView, and then do the UI layout based on the Sizeclass type. And can be in Uiviewcontroller's-willtransitiontotraitcollection:withtransitioncoordinator: and-viewwilltransitiontosize: Withtransitioncoordinator: Gets the new Sizeclass type when it is called, and then adjusts to the new UI layout. UI layout is mainly to deal with the constraints between views to achieve AutoLayout, if you use Apple native API to write the constraints of view, the code will be more, the interface layout of the code will be a bit messy; You can write AutoLayout code with a third-party library, This can reduce a lot of code, such as Masonry,purelayout. The code for the layout in this demo is roughly as follows:

-(void) Willtransitiontotraitcollection: (nonnull uitraitcollection *) newcollection Withtransitioncoordinator: ( Nonnull id<uiviewcontrollertransitioncoordinator>) Coordinator {

if (uiuserinterfacesizeclasscompact = = Newcollection.horizontalsizeclass) {

[Self layoutallsubviews:yes];

} else {

[Self layoutallsubviews:no];

}

}

-(void) Layoutallsubviews: (BOOL) Iscompactlayout {

int padding = 20;

if (iscompactlayout) {

[Self.greenview mas_remakeconstraints:^ (Masconstraintmaker *make) {

Make.top.equalTo (superview.mas_top). offset (padding);

}];

} else {

[Self.greenview mas_remakeconstraints:^ (Masconstraintmaker *make) {

Make.top.greaterThanOrEqualTo (superview.mas_top). offset (padding);

}];

}

}

The results of this demo run are as follows, in W:compact H:regular This Sizeclass case shows 3 rows, each row of a view, in W:regularh:regular this sizeclass case display 2 rows, The first row shows two views

Figure 8 Demo View Split

Figure 9 Demo View Split

A few small details

    1. Uiscreen.bounds and Uiwindow.bounds are no longer the same size, UIWindow may only be 1/2 or 1/3 of the screen.
    2. The Size Class is changed, as mentioned in the article above. The User experience section needs to be considered during development (if there is no designer, it is automatically ignored · ), including UI design and change-of-size transitions that fit the screen size. You can try Transitioncoordinator's-animatealongsidetransition: To animate the layout to make the switch more natural.
    3. If your app doesn't use the slide over and split view features, your app won't appear in the slide over area, even though your app is running in a multitasking environment.
    4. Need to consider the version supported by the app, if you need to support IOS 6 God horse, be ready to cry, version judgment and so on.
    5. Pay attention to the reasonable allocation of memory, listen to memories warning to facilitate the release of Cache and unnecessary View Controller, avoid circular references and so on
    6. Even in the Split view mode, the app has to continue to run in its own Shahe (Sandbox), to achieve real-world interaction between apps, and a long way to go

Reference links

https://developer.apple.com/library/prerelease/ios/documentation/WindowsViews/Conceptual/ adoptingmultitaskingonipad/index.html#//apple_ref/doc/uid/tp40015145

Https://www.hackingwithswift.com/read/31/5/ipad-multitasking-in-ios-9

Http://www.cocoachina.com/ios/20150714/12555.html

http://onevcat.com/2014/07/ios-ui-unique/

http://blog.devtang.com/blog/2015/03/22/ios-dev-controversy-2/

Https://github.com/SnapKit/Masonry

Https://github.com/smileyborg/PureLayout

All rights reserved, reprint must indicate the author (jintian) and original source (original).

IOS 9 Split-screen multitasking (multitasking)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.