无法覆盖 prefersHomeIndicatorAutoHidden() 方法 [英] Cannot override prefersHomeIndicatorAutoHidden() method
问题描述
我在带有 XCode 10 的应用程序中使用了这行代码,以便在 iPhone X 和相关的无边苹果设备上调暗主页指示灯.
override func prefersHomeIndicatorAutoHidden() ->布尔{返回真}
现在有趣的是,我有这个应用程序的精确副本,并且在一个副本上代码可以运行,而代码不能编译:
<块引用>方法不会覆盖其超类中的任何方法
确实,当我开始输入 "prefers..." 时,prefersHomeIndicatorAutoHidden 一方面显示为只读属性,另一方面它确实显示为方法,并且默认获取覆盖前缀.
>感谢您抽出宝贵时间
最佳
感谢 @inokey
使用解决方案进行编辑方案一:检查部署(从i0S 12开始,
prefersHomeIndicatorAutoHidden
不能作为方法被覆盖)解决方案 2:
override var prefersHomeIndicatorAutoHidden : Bool { return true }
我假设 Xcode 10 中的默认部署目标是 12,而你之前的项目是 11 或 10,所以它只是反映了 API 的变化.
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 }
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
这篇关于无法覆盖 prefersHomeIndicatorAutoHidden() 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!