Is it possible to opt your iPad app out of multitasking on iOS 9
You have to modify your project to support multitasking. According to WWDC 2015 video, to adopt your app for multitasking, satisfy these requirements:
- Build your app with iOS 9 SDK
- Support all orientations
- Use Launch Storyboards
So, if any of this is not done yet, your app will not be able to support multitasking.
Of course, if you don't use size classes, put it at the top of the list.
Edit: according to you question edit. There is a UIRequiresFullScreen key in Info.plist. See more at Apple docs
Is iPhone supported for multi-tasking in iOS 9
iPhone and iPod touch users cannot use the multitasking features of iOS 9.
Multitasking is only available on:
- iPad Air
- iPad Air 2
- iPad mini 2
- iPad mini 3
Note: Split View is only available on the iPad Air 2
See for more information about multitasking: https://developer.apple.com/library/prerelease/ios/documentation/WindowsViews/Conceptual/AdoptingMultitaskingOniPad/index.html
Handle another app's obscuring keyboard on iPad split view (iOS 9 multitasking)
The secret is to listen to the UIKeyboardWillChangeFrame
notification that is triggered whenever the keyboard is shown/hidden from your app or from another app running side by side with yours.
I created this extension to make it easy to start/stop observing those events (I call them in viewWillAppear
/Disappear
), and easily get the obscuredHeight
that is usually used to adjust the bottom contentInset
of your table/collection/scrollview.
@objc protocol KeyboardObserver
{
func startObservingKeyboard() // Call this in your controller's viewWillAppear
func stopObservingKeyboard() // Call this in your controller's viewWillDisappear
func keyboardObscuredHeight() -> CGFloat
@objc optional func adjustLayoutForKeyboardObscuredHeight(_ obscuredHeight: CGFloat, keyboardFrame: CGRect, keyboardWillAppearNotification: Notification) // Implement this in your controller and adjust your bottom inset accordingly
}
var _keyboardObscuredHeight:CGFloat = 0.0;
extension UIViewController: KeyboardObserver
{
func startObservingKeyboard()
{
NotificationCenter.default.addObserver(self, selector: #selector(observeKeyboardWillChangeFrameNotification(_:)), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil)
}
func stopObservingKeyboard()
{
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil)
}
func observeKeyboardWillChangeFrameNotification(_ notification: Notification)
{
guard let window = self.view.window else {
return
}
let animationID = "\(self) adjustLayoutForKeyboardObscuredHeight"
UIView.beginAnimations(animationID, context: nil)
UIView.setAnimationCurve(UIViewAnimationCurve(rawValue: (notification.userInfo![UIKeyboardAnimationCurveUserInfoKey]! as AnyObject).intValue)!)
UIView.setAnimationDuration((notification.userInfo![UIKeyboardAnimationCurveUserInfoKey]! as AnyObject).doubleValue)
let keyboardFrame = (notification.userInfo![UIKeyboardFrameEndUserInfoKey]! as AnyObject).cgRectValue
_keyboardObscuredHeight = window.convert(keyboardFrame!, from: nil).intersection(window.bounds).size.height
let observer = self as KeyboardObserver
observer.adjustLayoutForKeyboardObscuredHeight!(_keyboardObscuredHeight, keyboardFrame: keyboardFrame!, keyboardWillAppearNotification: notification)
UIView.commitAnimations()
}
func keyboardObscuredHeight() -> CGFloat
{
return _keyboardObscuredHeight
}
}
iPad Multitasking support requires these orientations
iPad Multitasking support requires all the orientations but your app does not, so you need to opt out of it, just add the UIRequiresFullScreen
key to your Xcode project’s Info.plist
file and apply the Boolean value YES
.
Testing multitasking iOS 9 feature in simulator
You can test it.
Just run ios simulator iPad Air 2 (ios 9)( because only this device supports Split View) and swipe from right to left near of middle edge of the screen
How to use AVCaptureSession with Slide Over and Split View in iOS 9?
In case you haven't found out yet. After some more investigation I can now answer your first question:
If AVCaptureSession is immediately paused when Slide Over and Split
View are used, is it a good idea to monitor
AVCaptureSessionDidStopRunningNotification, and present a message
"Camera Paused" to the user, so that he clearly knows that the app
isn't performing scanning?
The notification you actually want to observe is this one: AVCaptureSessionWasInterruptedNotification
And you want to check for the newly introduced in iOS9 reason: AVCaptureSessionInterruptionReason.VideoDeviceNotAvailableWithMultipleForegroundApps
override func viewWillAppear(animated: Bool)
{
super.viewWillAppear(animated)
self.addObserverForAVCaptureSessionWasInterrupted()
}
func addObserverForAVCaptureSessionWasInterrupted()
{
let mainQueue = NSOperationQueue.mainQueue()
NSNotificationCenter.defaultCenter().addObserverForName(AVCaptureSessionWasInterruptedNotification, object: nil, queue: mainQueue)
{ (notification: NSNotification) -> Void in
guard let userInfo = notification.userInfo else
{
return
}
// Check if the current system is iOS9+ because AVCaptureSessionInterruptionReasonKey is iOS9+ (relates to Split View / Slide Over)
if #available(iOS 9.0, *)
{
if let interruptionReason = userInfo[AVCaptureSessionInterruptionReasonKey] where Int(interruptionReason as! NSNumber) == AVCaptureSessionInterruptionReason.VideoDeviceNotAvailableWithMultipleForegroundApps.rawValue
{
// Warn the user they need to get back to Full Screen Mode
}
}
else
{
// Fallback on earlier versions. From iOS8 and below Split View and Slide Over don't exist, no need to handle anything then.
}
}
}
override func viewWillDisappear(animated: Bool)
{
super.viewWillDisappear(true)
NSNotificationCenter.defaultCenter().removeObserver(self)
}
You can also know when the interruption was ended by observing:
AVCaptureSessionInterruptionEndedNotification
Answer based on these two links:
http://asciiwwdc.com/2015/sessions/211
https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html
Related Topics
iOS Uinavigationbar Button Remains Faded After Segue Back
Error When Adding Input View to Textfield iOS 8
How to Implement a Pop-Up Dialog Box in iOS
Secitemadd and Secitemcopymatching Returns Error Code -34018 (Errsecmissingentitlement)
Drop-Down List in Uitableview in iOS
In Swift, Array [String] Slicing Return Type Doesn't Seem to Be [String]
Uilabel Layer Cornerradius Negatively Impacting Performance
Failed to Read Values in Cfprefsplistsource iOS 10
Navigationlink Works Only for Once
App Rejected Because of "Missing Push Notification Entitlement"
How to Find File Uti for File, Withouth Pathextension, in a Path in Swift
Converting iPhone Xib to iPad Xib
Uialertview First Deprecated iOS 9
iOS 13: Swift - 'Set Application Root View Controller Programmatically' Does Not Work