gpt4 book ai didi

ios - UIViewController 覆盖

转载 作者:行者123 更新时间:2023-11-30 12:08:24 25 4
gpt4 key购买 nike

我在重写 UIVC 方法时遇到一些麻烦(错误:方法不会重写其父类(super class)中的任何方法),我做错了什么?

带有supportedInterfaceOrientation的代码示例,它不会导致错误,但仍然不会覆盖并且无法工作。

func supportedInterfaceOrientations() -> UIInterfaceOrientationMask{
return UIInterfaceOrientationMask(rawValue:(UIInterfaceOrientationMask.portrait.rawValue | UIInterfaceOrientationMask.landscape.rawValue))}

截图问题 enter image description here

最佳答案

supportedInterfaceOrientations 是计算属性,而不是函数:

https://developer.apple.com/documentation/uikit/uiviewcontroller/1621435-supportedinterfaceorientations

所以错误是正确的 - 父类(super class)中没有这样的函数。

func 替换为 var,将 () -> 替换为 :

关于ios - UIViewController 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46392287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com