Interface Builder 在 MacRuby 中看不到 Outlet

发布于 2024-10-10 05:37:17 字数 958 浏览 6 评论 0原文

我正在尝试使用 XCode 和 Interface Builder 构建一个基本的 hello world 应用程序。但是,在 Interface Builder 中我看不到连接的插座。我转到对象检查器窗格的连接选项卡,它显示“新引用插座”。

我想知道我的代码是否错误。据

class HelloWorldController 
    attr_accessor :hello_label, :hello_button, :hello

    def awakeFromNib 
        @hello = true
    end

    def changeLabel(sender) 
        if @hello
            @hello_label.stringValue = "Good Bye" 
            @hello_button.title = "Hello" 
            @hello = false
        else
            @hello_label.stringValue = "Hello World" 
            @hello_button.title = "Good Bye" 
            @hello = true
        end 
    end
end

我了解,我应该能够看到 hello、hello_label、hello_button 和 changeLabel,但我看不到。我想也许我在某个地方拼写错误,但似乎也不是这样。这是两个界面生成器窗口的截图。

alt text

感谢任何帮助。我想我只是忽略了一些事情,但不确定。

更新:我通过重新安装 OS X 解决了这个问题。我怀疑有问题,因为安装了 X Code 4,不知道。不过,它现在可以与全新安装的 OS X、X Code 和 MacRuby 一起使用

I am trying to get a basic hello world application going using XCode and Interface Builder. However, in Interface Builder I can't see my outlets to wire things up with. I go to the connections tab of the objects inspector pane and it says "New Referencing Outlet".

I am wondering if my code is wrong. Here it is

class HelloWorldController 
    attr_accessor :hello_label, :hello_button, :hello

    def awakeFromNib 
        @hello = true
    end

    def changeLabel(sender) 
        if @hello
            @hello_label.stringValue = "Good Bye" 
            @hello_button.title = "Hello" 
            @hello = false
        else
            @hello_label.stringValue = "Hello World" 
            @hello_button.title = "Good Bye" 
            @hello = true
        end 
    end
end

As I understand it I should be able to see hello, hello_label, hello_button, and changeLabel, but I don't. I thought maybe I had a misspelling somewhere, but that doesn't seem to be it either. Here is a shot of the two interface builder windows.

alt text

Any help is appreciated. I think I am just overlooking something, but not sure.

UPDATE: I solved the problem by just re-installing OS X. I suspect there was a problem because X Code 4 was installed, no idea. However, it now works with a fresh install of OS X, X Code and MacRuby

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

旧故 2024-10-17 05:37:17

I had a similar problem
http://www.mail-archive.com/[email protected]/msg05331.html

it was fixed by reinstalling MacRuby after a reinstall of XCode.

清风挽心 2024-10-17 05:37:17

如果您使用的是 XCode 4.1 或 4.2,则无需重新安装,就像我刚才所做的那样 - 它现在确实坏了。请参阅此票证了解修复时间和解决方法。

No need to reinstall if you are on XCode 4.1 or 4.2, like I just did - it is truly broken now. See this ticket for when it is fixed, and a workaround.

紫瑟鸿黎 2024-10-17 05:37:17

如果您升级到 Xcode 4.3+,则需要遵循以下说明:

http://lldong.github.com/blog/2012/03/05/xcode-4-dot-3-macruby-兼容-problem-workaround/

它将为您的 Macruby 项目模板提供支持并修复 rb_nibtool

If you upgrade to Xcode 4.3+, you will need to follow these instructions:

http://lldong.github.com/blog/2012/03/05/xcode-4-dot-3-macruby-compatible-problem-workaround/

It will bring bace your Macruby project templates and fix rb_nibtool

不喜欢何必死缠烂打 2024-10-17 05:37:17

安装的 MacRuby 附带文件和项目模板以及允许 IB/Xcode 将 UI 元素链接到 MacRuby 代码的工具,反之亦然。在某些情况下,升级 Xcode 或安装 iOS SDK 会破坏 Xcode 桥,您需要重新安装 MacRuby。请注意,如果 Xcode4 仅在 MacRuby 0.10 或更高版本中受支持。 (我今天刚刚在 trunk 中编辑了 Xcode 4 模板,几天后它们应该会随 0.10 版本一起发布)。

MacRuby installed comes with file and project templates and a tool that allows IB/Xcode to link UI elements to MacRuby code and vice-versa. In some cases, upgrading Xcode or installing the iOS SDK breaks the Xcode bridge and you need to reinstall MacRuby. Note that if Xcode4 is only supported in MacRuby 0.10 or more recent. (I just edited the Xcode 4 templates today in trunk and they should go out with the 0.10 release in a few days).

感性 2024-10-17 05:37:17

此问题已在 Xcode 4.2 中得到解决。

This issue has been resolved in Xcode 4.2.

梦幻之岛 2024-10-17 05:37:17

正如另一个答案所示,Xcode 4.1 有一个错误,即 IB 无法识别 MacRuby 类中的出口。它在 Xcode 4.2 中得到纠正。但是,如果升级到 4.2,则必须重新安装 MacRuby,MacRuby 商店才能重新开始工作。

As indicated in another answer, Xcode 4.1 had a bug where IB did not recognize outlets in MacRuby classes. It is corrected in Xcode 4.2. However, if you upgrade to 4.2, you must then reinstall MacRuby for MacRuby outlets to start working again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文