개발중인 앱을 변경해야하며 풀 타임 iOS 개발자가 아닙니다. 실행 있지만 (그들이 layoutAttributesForElementsinRect
를 오버라이드 (override) 자신의 사용자 정의 UICollectionViewLayout에서 https://www.raywenderlich.com/107439/uicollectionview-custom-layout-tutorial-pinterestSwift의 UICollectionViewLayout에서 오류가있는 메소드를 오버라이드
하지만 난 엑스 코드 (8) 컴파일러에서 오류를 받고 있어요 : 나는 iOS 앱에 대한 인터페이스와 같은 클립을 얻으려고 여기 자습서를하고 있어요 Legacy Swift Language Version을 Yes로 설정).
내가 오류는 다음과 같습니다 Method does not override any method from its superclass
축약 된 코드는 다음과 같습니다
class PinterestLayout: UICollectionViewLayout {
....
override func layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]? {
var layoutAttributes = [UICollectionViewLayoutAttributes]()
// Loop through the cache and look for items in the rect
for attributes in cache {
if CGRectIntersectsRect(attributes.frame, rect) {
layoutAttributes.append(attributes)
}
}
return layoutAttributes
}
나는 컴파일하지만 작동하지 않고 내가 재정의를 제거하면, 그것은 준다 비공개로 방법을 전환하는 경우 나 갈등. 기본 메서드를 재정의하고 싶지만이를 작동시키는 방법을 모르겠습니다.
하지 3.0 –
@Ahmad 예, 그 근본 원인이다이어야한다. 'override' 키워드의 (지금) 오용으로 던져진 오류는 여러분이 그것을 잡을 수있는 증상입니다. – Alexander
thx - 그게 문제였습니다. – timpone