2013-04-18 52 views
0

我下面的motioncasts抓屏即可在: http://motioncasts.tv/start-building-views-in-rubymotion/RubyMotion未定義的方法`addTarget」爲#<UIRoundedRectButton:0x761fd40>

並有一些代碼:

button = UIButton.buttonWithType(UIButtonTypeRoundedRect) 
button.frame = [[15, 300], [280,50]] 
button.setTitle("Move to next view", forState: UIControlStateNormal) 
button.addTarget(self, 
       action: "moveToChildView:", 
       formControlEvents: UIControlEventTouchUpInside) 

這是爲了工作,但當試圖編譯產生的錯誤:

(main)> 2013-04-18 18:41:06.205 12wbt[76267:c07] home_controller.rb:19:in `viewDidLoad': undefined method `addTarget' for #<UIRoundedRectButton:0x761fd40> (NoMethodError) 
    from app_delegate.rb:6:in `application:didFinishLaunchingWithOptions:' 
2013-04-18 18:41:06.208 12wbt[76267:c07] *** Terminating app due to uncaught exception 'NoMethodError', reason: 'home_controller.rb:19:in `viewDidLoad': undefined method `addTarget' for #<UIRoundedRectButton:0x761fd40> (NoMethodError) 
    from app_delegate.rb:6:in `application:didFinishLaunchingWithOptions:' 
' 

據我可以告訴,這是來自screencast應該w的確切代碼ork沒有錯誤。哪裏不對?

回答

0

問題已解決。最後一行應爲forControlEvents,而不是formControlEvents

相關問題