2017-01-13 43 views
3

我有最簡單的用戶界面 - 只有一個按鈕:從Interface Builder來enter image description here的UIButton停止顯示在界面生成器UIControl行動將擴展到它後

正如你看到的,我可以任意拖動事件(如UITouchUpInside)我碼。

,但如果我的一些擴展添加到UIButton的一樣:

protocol SomeProtocol {} 

extension UIButton: SomeProtocol {} 

這些事件不再可見: enter image description here

我使用的Xcode 8.2版(8C38)

我能以某種方式回報他們?這是Xcode中的錯誤嗎?

回答

3

這似乎是一個Xcode錯誤。

可以嘗試的解決方法是使用協議來擴展UIControl。 UIControl是UIButton的超類,因此UIControl 的擴展被UIButton繼承,並且當UIControl採用 協議時,Xcode似乎不會感到不安。

protocol SomeProtocol { } 

extension UIControl: SomeProtocol { } 

從蘋果開發者論壇

Adding a Swift protocol to UIButton breaks Interface Builder action options.

0

我遇到過類似的問題,我無法將自定義類鏈接到插座和IBActions。 在我的情況下,我不得不使用標準的UIKit類將我的對象鏈接到IBOutlet,然後修改了代碼以適應我的需要。

相關問題