2016-12-12 44 views
1

我想創建一個自定義的視圖,我需要關注。 根據許多來源,這是要走的路:canBecomeFocus on swift 3

override func canBecomeFocused() -> Bool { 
    return true 
} 

但是轉換爲雨燕3.0在此之後不再有效。 它引發錯誤:

Method does not override any method from its superclass.

如果我刪除重寫另一個錯誤被拋出:

Method 'canbecomeFocused()' with Objective-C selector 'canBecomeFocused' conflicts with better for 'canBecomeFocused' from superclass 'UIView' with the same Objective-C Selector.

無論如何,我可以做一個UIView可選擇的TvOS?

+0

在我的swift 3代碼我能夠覆蓋此屬性,所以請再試一次。 –

+0

即時通訊將看我是否可以更新xCode。它是奇怪的我在8.0 beta 4 ..現在8.2(最新) –

+0

我工作在Xcode 8及其工作。 –

回答

2

在Swift 3中,更改爲Instance Property,所以試試這樣。

override var canBecomeFocused: Bool { 
    return true 
} 

有關更多詳細信息,請參閱canBecomeFocused的Apple文檔。