2016-07-25 52 views
0

基本上,我一直在使用Apple開始開發iOS應用程序(Swift)進行學習,並且我遇到了一些根本無法使用的代碼 - 蘋果版本。有關XCode中選擇器的快速問題(Swift)

button.addTarget(self, action: #selector(RatingControl.ratingButtonTapped(_:)), 
forControlEvents: .TouchDown) 

,並且錯誤是:

  1. 預期 '' 分隔符(在...之間 「動作:」 和 「#selector」 兩次)

  2. 預期表達在表達式

  3. 列表
+0

可能重複[@selector()在Swift?](http://stackoverflow.com/questions/24007650/selector-in-swift) – fuzz

+0

@gotnull - 改變#選擇器 - > @選擇器()仍然給我錯誤#2 –

+1

你運行的是哪個版本的Xcode? – dan

回答

0

您必須在代碼中定義funcion ratingButtonTapped()。

+0

如果你不使用xcode版本7.3或更高版本,你可以嘗試像這樣定義選擇器: action:Selector(「funcName」) –