如何在没有Interface Builder的情况下创建Cocoa接口? [英] How do I create Cocoa interfaces without Interface Builder?

查看:156
本文介绍了如何在没有Interface Builder的情况下创建Cocoa接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢以编程方式创建我的界面。似乎Apple开发人员的所有文档都假定您使用的是Interface Builder。是否可以以编程方式创建这些接口,如果是这样,我将从哪里开始学习如何做这个

I would prefer to create my interfaces programatically. Seems as if all the docs on Apple Developer assume you're using Interface Builder. Is it possible to create these interfaces programatically, and if so where do I start learning about how to do this

我认为相关的文档,如果可能的话,本部分: http://developer.apple.com/referencelibrary/Cocoa/idxUserExperience -date.html

I thought the relevant document for this, if possible would be in this section: http://developer.apple.com/referencelibrary/Cocoa/idxUserExperience-date.html

推荐答案


我喜欢以编程方式创建我的界面。 / p>

I would prefer to create my interfaces programatically.

为什么? Interface Builder更容易,更快。你不能通过拖放来写错字,当你用手打字矩形时,你不会得到那些非常方便的Aqua指南。

Why? Interface Builder is easier and faster. You can't write a typo by drag and drop, and you don't get those oh-so-handy Aqua guides when you're typing rectangles by hand.

不要打它。 Interface Builder是您的朋友。让它帮助你。

Don't fight it. Interface Builder is your friend. Let it help you.

如果你坚持通过在代码中编写你的UI浪费你自己的时间和精力:

If you insist on wasting your own time and energy by writing your UI in code:

不是基于文档的(通常基于库的,如邮件,iTunes,iPhoto):创建NSObject的子类,实例化它,并将其作为应用程序的委托,并在委托的 applicationDidFinishLaunching:方法,创建一个窗口,用视图填充它,然后排序。

Not document-based (generally library-based, like Mail, iTunes, iPhoto): Create a subclass of NSObject, instantiate it, and make it the application's delegate, and in the delegate's applicationDidFinishLaunching: method, create a window, populate it with views, and order it front.

基于文档Preview,QuickTime Player):在NSDocument子类中的 makeWindowControllers 方法中,创建你的窗口(并用视图填充它们)并为它们创建窗口控制器,确保发送 addWindowController:

Document-based (like TextEdit, Preview, QuickTime Player): In the makeWindowControllers method in your subclass of NSDocument, create your windows (and populate them with views) and create window controllers for them, making sure to send yourself addWindowController: for each window controller.

这篇关于如何在没有Interface Builder的情况下创建Cocoa接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆