无法覆盖 prefersHomeIndicatorAutoHidden() 方法 [英] Cannot override prefersHomeIndicatorAutoHidden() method

查看:34
本文介绍了无法覆盖 prefersHomeIndicatorAutoHidden() 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在带有 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆