XCode 8,一些方法消失了?例如:layoutAttributesClass() ->任何类 [英] XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass

查看:29
本文介绍了XCode 8,一些方法消失了?例如:layoutAttributesClass() ->任何类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 collectionView & 上遇到了一些问题Xcode 8 + Swift 3 项目上的 collectionViewLayout.

I encounter some issues on collectionView & collectionViewLayout on Xcode 8 + Swift 3 project.

似乎有些方法完全消失了.

It's seems some methods totally disappeared.

例如,当我继承 UICollectionViewFlowLayout 时:

For example, when I subclass UICollectionViewFlowLayout:

override func layoutAttributesClass() -> AnyClass

此触发 xcode 错误:

This trigger xcode error:

Method does not override Any Method from his superclass

此方法的文档:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionViewLayout_class/index.html#//apple_ref/occ/clm/UICollectionViewLayout/layoutAttributesClass

不确定它是否与 Xcode 8 相关,因为我在 Xcode 7 和 swift 2.3 上的 collectionView 已经有一些奇怪的问题,例如,在 xcode 上没有检测到 itemSizeAtIndexPath 方法,但是如果我将该方法放在 collectionViewController 中,即使没有关键字覆盖它也会被调用.

Not sure it's Xcode 8 related because I already have strange issues with collectionView on Xcode 7 and swift 2.3, for example, itemSizeAtIndexPath method is not detected on xcode but if I put the method in a collectionViewController it's called even without the keyword override.

推荐答案

在 Swift 3 中,它是一个(类)属性而不是一个方法:

In Swift 3, it is a (class) property instead of a method:

override class var layoutAttributesClass: AnyClass {
    // ...
}

这篇关于XCode 8,一些方法消失了?例如:layoutAttributesClass() ->任何类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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