XCode iPad 分割视图控制器,带有包含多个表单控件的详细视图

发布于 11-25 07:09 字数 1188 浏览 0 评论 0原文

对于 Mac、XCode 3.2.6 和 iPad 来说相当新。我有一个相当简单的业务数据模型要在 iPad 上实现,但似乎找不到要使用的视图和控制器的组合。

这是一个简单的数据收集程序,但数据字段太多,无法在单个屏幕上显示,因此我采用了拆分视图方法。

我左边有八行表数据; RootViewController 是默认的 UITableViewController。我正在尝试编写程序,以便当选择任何这些表行时,右侧的视图(详细视图)将被重新绘制并填充一堆不同的控件(标签、按钮、文本字段等),对应于左侧的选择。目前,所有详细信息视图都是普通的 UIViewController。

例如,第一个“选项卡”的标题可能是“个人”,我需要显示字段来收集信息,例如姓名、出生日期、身高、体重等。下一个可能是“地址”,我需要在其中收集街道,城市,邮政编码等。下一个可能是“雇主”,我想在其中收集雇主的姓名,地址,电话号码等。这些大多是静态的且不变的,但有足够的字段用于大约 8屏幕价值。

我已经在 Interface Builder 中布置了所有这些内容,但是当我在 iPad 模拟器上运行它并单击第一个视图上的第一个按钮时,不会调用连接的委托。我在那里设置了一个断点,但没有被击中。

在 UISplitViewController 的右侧使用简单的 UIViewController 是否有一些特殊的魔力,让它们包含其他简单的 Label、TextBox 和 Button 控件?

另外,框架使用 RootViewController.h/.m 和 DetailViewController.h/.m 对构建原始启动代码是否有任何特殊的魔力?我是否正确地认为单个详细视图代表表视图右侧的整个 iPad 屏幕,并且为了添加更多“页面”,我们需要编写更多文件和 .XIB,例如 DetailViewController?

最后一个问题是如何实现这个应用程序的数据模型。我注意到当项目第一次自动创建时,没有任何模型的源文件。 (也许大多数预定义的应用程序类型不会自动为模型生成任何内容,但我知道这是模型-视图-控制器范例的重要组成部分。)无论如何,所有各种视图上的这些数据字段最终将成为我想要保存并从存储中加载的 SQLite 记录。我从哪里开始将所有这些东西连接到所有自动生成的“以视图为中心”的代码中?

如果有人看过类似这样的“如何为 iPad 编写真正的商业应用程序”网站,请发布链接。我并不是想在右侧的单个(重复使用)视图中显示各种水果的 jpeg;我正在尝试显示几个用于真实业务应用程序的真实数据收集的真实控件。

谢谢!

Fairly new to Mac and XCode 3.2.6 and iPad. I have a fairly simple business data model to implement on the iPad, but can't seem to find the combination of views and controllers to use.

It's a simple data collection program, but there are too many data fields to fit on a single screen so I've resorted to the Split View approach.

I've got eight rows of table data on the left; RootViewController is the default UITableViewController. I'm trying to write the program such that when any of those table rows are selected, the view on the right (Detail View) gets redrawn and populated with a bunch of different controls (labels, buttons, text fields, etc.) that correspond to the selection on the left. Currently all the Details views are plain UIViewControllers.

For instance, the first "tab" might be titled "Personal", and I need to display fields to collect info such as Name, DOB, Height, Weight, etc. The next one might be "Address" where I need to collect Street, City, ZIP Code, etc. The next one might be "Employer", where I'd like to collect the employer's name, address, phone number, etc. These are mostly static and unchanging, but there are enough fields for about 8 screens worth.

I've got all this laid out in Interface Builder, but when I run it on the iPad simulator and click the very first button on the very first view, the connected delegate isn't called. I've put a breakpoint there and it's not being hit.

Is there some special magic to using simple UIViewControllers on the right side of a UISplitViewController, as far as letting them contain other simple Label, TextBox, and Button controls?

Also is there any special magic in that the framework built the original start-up code with a RootViewController.h/.m and DetailViewController.h/.m pair? Am I correct in thinking that a single detail view represents the entire iPad screen to the right of the Table View, and that to add more "pages" we need to write more files and .XIBs like DetailViewController?

Final question is how to implement the data model for this app. I noticed when the project was first auto-created, there weren't any source files for the model. (Maybe most of the predefined app types don't auto-generate anything for the model, but I understand that's a big part of model-view-controller paradigm.) Anyway these data fields on all the various views will eventually be part of a SQLite record that I'd like to save and load from storage. Where would I begin to wire all that stuff in to all the auto-generated "view centric" code?

If anyone has seen a "how to write real business apps for the iPad" website along the lines of anything like this, please post the link. I'm not trying to display jpegs of various fruits in a single (reused) view on the right side; I'm trying to display several real controls for real-world data collection for a real business app.

Thanks!

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

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

发布评论

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

评论(2

方觉久2024-12-02 07:09:52

基本的事情(如果您还没有做过):
您是否已将用户从 INSIDE TOUCH UP 事件按下的界面对象连接到 IBOUTLET,然后刷新右侧?

如果你有,并且你已经搞砸了一些(即重命名和移动东西),请尝试从右键单击事件面板中删除它,然后再次将其重新连接到同一个 IBOUTLET (你不必删除任何代码).
另外,如果您指望某个未触发的事件触发,您应该搜索该事件(即 VIEWDIDLOAD NOT FIRING),因为这有时会被“破坏”(即与文件所有者没有连接),但更常见的是一个可能会误解何时实际被触发(即 VIEWDIDLOAD 与 VIEWDIDAPPEAR 与 VIEWWILLAPPEAR 等)

Basic things if you haven't already done them:
Have you connected the interface object the user is pressing from it's INSIDE TOUCH UP event to an IBOUTLET that then refreshes the right side?

If you have, and you've mucked about a bit (ie renaming and moving stuff around), try deleting it from the right-click event panel and then reconnecting it to the same IBOUTLET again (you don't have to delete any code).
Also, if you are counting on some event to fire that isn't firing, you should search on that (ie VIEWDIDLOAD NOT FIRING) because that can both occasionally be "broken" (ie no connection to the Files Owner) but more often one might misunderstand when that actually gets fired (ie VIEWDIDLOAD vs VIEWDIDAPPEAR vs VIEWWILLAPPEAR etc.)

星光不落少年眉2024-12-02 07:09:52

对于您的数据模型,CoreData 是您的朋友。它提供了一种面向模型的方法,并且可以轻松地保存数据。

对于您的导航需求,我认为 tabBarController 更适合您的需求。

从主视图更改详细信息视图可能很麻烦,尤其是在使用 NavigationController 作为详细信息视图时。我发现最好的方法是使用 NSNotificationCenter。

当使用 UISplitview 时,我强烈建议仅在业务需求时才支持 iPad - iOs 8 中进行了一些更改,使其更易于使用。

For your data model, CoreData is your friend. It provides a modell-oriented approach and easily allows to persist data.

For your navigation needs, I think a tabBarController better suits your needs.

Changing the detail view from the master view can be troublesome, especially when using a NavigationController as detail view. The best way I've found is using the NSNotificationCenter.

When using UISplitview I strongly recommend to support the iPad only when it's a business requirement - there are some changes in iOs 8 that make easier to use.

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