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

标签 swift

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/

相关文章:

ios - 类 'ProductDetailViewController' 没有初始化器

ios - iPhone X 主页指示器行为

Swift 字符串到 ascii 数组 Cyrillic

objective-c - 在 View Controller 和 OS X 之间转换

ios - 可扩展的 ListView 不会 swift 折叠

ios - 在没有观察者的情况下检测 iOS 应用程序移至后台

swift - RxAlamofire 使用 json 主体进行 post 调用

ios - 我如何知道应用程序是否通过 AppDelegate didFinishLaunchingWithOptions 处的 Firebase-Deep Link(动态链接)启动

ios - 如何使用动态单元格设置 View (UITableview)的背景?

Swift 标记 : Callback argument breaks documentation string