The multitasking features got updates in iOS 11, one of those was slide over which is demonstrated in the gif below.
With these changes it's no longer possible to use the techniques that check frame size from iOS 9 to detect if another app is a "slide over" over my app.
Is there any new method to detect if another app is running as slide over?
Hi. You can open two apps without using the dock, but you need the secret handshake: Open Split View from the Home screen. Touch and hold an app on the Home screen or in the Dock, drag it a finger's width or more, then continue holding it while you tap a different app with another finger.
Switch between apps in Slide Over Swipe right along the bottom of the Slide Over window, or do the following: Swipe halfway up the screen from the bottom of the Slide Over window, pause, then lift your finger. All the Slide Over windows appear. Tap the app you want to view, if it's visible.
On iPhone, multitasking lets people use FaceTime or watch a video in Picture in Picture while they also use a different app. The app switcher displays all currently open apps. A current FaceTime call can continue while people use another app.
I was able to get this working fairly easily on an iPad Pro (which supports side-by-side apps, not just slide-overs). Here's the code:
class ViewController: UIViewController {
override func viewWillLayoutSubviews() {
isThisAppFullScreen()
}
@discardableResult func isThisAppFullScreen() -> Bool {
let isFullScreen = UIApplication.shared.keyWindow?.frame == UIScreen.main.bounds
print("\(#function) - \(isFullScreen)")
return isFullScreen
}
}
The end result is that it will print "true" if the view is full screen and "false" if it's sharing the screen with another app, and this is run every time anything is shown, hidden, or resized.
The problem then is older devices that only support slide-over. With these, your app is not being resized anymore. Instead, it's just resigning active use and the other app is becoming active.
In this case, all you can do is put logic in the AppDelegate
to look for applicationWillResignActive
and applicationDidBecomeActive
. When you slide-over, you get applicationWillResignActive
but not applicationDidEnterBackground
.
You could look for this as a possibility, but you cannot distinguish between a slide-over and a look at the Notifications from sliding down from the top of the screen. It's not ideal for that reason, but monitoring application lifecycle is probably the best you can do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With