13

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?

Robin Andersson
  • 5,150
  • 3
  • 25
  • 44
  • 8
    Someone down voted and voted this question to be closed for being "Too broad" - I do not understand how you could get more detailed without proposing an answer to the question. If you feel that you need more information about the question, comment instead of voting for close. – Robin Andersson Sep 27 '17 at 08:37
  • An update is that I spent quite a lot of time trying to find something to solve this - but there is no public method to check if another app is running as slide over as far as I can see. – Robin Andersson Dec 18 '17 at 16:03
  • It states in the documentation that applicationWillResignActive will be called when user adds a slide over app. Maybe you can build your own solution from the information found here: https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/AdoptingMultitaskingOniPad/QuickStartForSlideOverAndSplitView.html#//apple_ref/doc/uid/TP40015145-CH13-SW1 – Maurice Dec 18 '17 at 18:59

1 Answers1

5

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.

David S.
  • 6,567
  • 1
  • 25
  • 45