gpt4 book ai didi

ios - RubyMotion 错误

转载 作者:行者123 更新时间:2023-11-28 22:20:21 28 4
gpt4 key购买 nike

我刚开始学习 ruby​​ motion,在教程开始时我遇到了障碍!教程是《RubyMotion iOS 开发精要》。

这是我的代码:

class RootController < UIViewController
def viewDidLoad
alert = UIAlertView.alloc.initWithTitle "This is foo title",
message:"Do you like this example?",
delegate: nil,
cancelButtonTitles: "cancel",
otherButtonTitles: "Yes", "No", nil
alert.show
end
end

我知道缩进看起来很有趣,但显然那是 RubyMotion 语法……很奇怪,我知道。这是我收到的关于“initWithTitle”方法的错误:

(main)> 2013-12-13 00:44:40.780 HelloWorld[97435:80b] root_controller.rb:7:in `viewDidLoad': undefined method `initWithTitle' for #<UIAlertView:0x8d2bcf0> (NoMethodError)
from app_delegate.rb:6:in `application:didFinishLaunchingWithOptions:'
2013-12-13 00:44:40.782 HelloWorld[97435:80b] root_controller.rb:7:in `viewDidLoad': undefined method `initWithTitle' for #<UIAlertView:0x8d2bcf0> (NoMethodError)
from app_delegate.rb:6:in `application:didFinishLaunchingWithOptions:'
2013-12-13 00:44:40.784 HelloWorld[97435:80b] *** Terminating app due to uncaught exception 'NoMethodError', reason: 'root_controller.rb:7:in `viewDidLoad': undefined method `initWithTitle' for #<UIAlertView:0x8d2bcf0> (NoMethodError)
from app_delegate.rb:6:in `application:didFinishLaunchingWithOptions:'

'

如果有任何指点,我将不胜感激,这么早就陷入困境真是太可惜了!

最佳答案

cancelButtonTitles 应该是单数:cancelButtonTitle

因为您使用的是复数措辞,所以找不到匹配的方法签名。

关于ios - RubyMotion 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20576045/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com