gpt4 book ai didi

swift - 方法不会覆盖 Swift3 中其父类(super class)的任何方法?

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

override func layoutAttributesForElements(in rect: CGRect) -> [AnyObject]? {
var layoutAttributes = [UICollectionViewLayoutAttributes]()
// Loop through the cache and look for items in the rect
for attributes in cache {
if attributes.frame.intersects(rect ) {
layoutAttributes.append(attributes)
}
}
return layoutAttributes }

这里我收到错误。

Method does not override any method from it's superclass.

如何解决该问题。

谁能帮帮我。

提前致谢。

最佳答案

如果您确实尝试在正确的位置重写该方法,请尝试删除方法名称并输入 override func layoutAttributes 并从自动完成中选择正确的重写。有时会出现此类问题,是因为不同版本的 Swift 的语法发生了变化

关于swift - 方法不会覆盖 Swift3 中其父类(super class)的任何方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44583816/

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