Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot override prefersHomeIndicatorAutoHidden() method

I use this line of code in an app with XCode 10 in order to dim the home indicator on iPhone X and associated edgeless apple devices.

    override func prefersHomeIndicatorAutoHidden() -> Bool {
        return true
    }

Now the funny thing is, I have an exact copy of this app and on one copy the code works, whilst on the over the code does not compile:

Method does not override any method from its superclass

Indeed when I start typing "prefers..." , prefersHomeIndicatorAutoHidden appears as a read-only property on the one hand, whilst it does appear as a method on the other hand, and gets the override prefix by default.

Thanks for taking the time,

Best

EDIT WITH SOLUTIONS thanks to @inokey

  • Solution 1: check deployment (starting i0S 12, prefersHomeIndicatorAutoHidden cannot be overridden as a method)

  • Solution 2 :

override var prefersHomeIndicatorAutoHidden : Bool { return true }
like image 995
Chris Avatar asked Sep 18 '18 12:09

Chris


2 Answers

I assume that default deploy target in Xcode 10 is 12 and your previous project is 11 or 10, so it just reflects the changes in API.

Changes in SDK indicate that this was changed

enter image description here

like image 166
inokey Avatar answered Sep 30 '22 05:09

inokey


in Xcode 10 = Swift 4.2 (Sep 2018)

Just use the code below:

override var prefersHomeIndicatorAutoHidden: Bool { return true }
like image 44
hadeneh Avatar answered Sep 30 '22 06:09

hadeneh