Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if another app is running as slide over in iOS 11?

Tags:

ios

ipad

ios11

The multitasking features got updates in iOS 11, one of those was slide over which is demonstrated in the gif below.

enter image description here

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?

like image 252
Robin Andersson Avatar asked Sep 27 '17 08:09

Robin Andersson


People also ask

Can iPhone run 2 apps same time?

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.

How do I switch between slide over apps?

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.

Does IOS have Multitasking?

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.


Video Answer


1 Answers

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.

like image 133
David S. Avatar answered Oct 09 '22 06:10

David S.