首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RubyMotion错误

RubyMotion错误
EN

Stack Overflow用户
提问于 2013-12-13 21:10:44
回答 1查看 289关注 0票数 0

我刚刚开始学习红宝石运动,在一个教程的开始,我遇到了一个路障!本教程是"RubyMotion iOS开发要点“。

这是我的代码:

代码语言:javascript
复制
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“方法的错误:

代码语言:javascript
复制
(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:'

我很感激你的指点,这么早就被困在这里真是太令人沮丧了!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-13 22:36:20

cancelButtonTitles应该是单数:cancelButtonTitle

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20576045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档