iPhone Contact 应用的详细视图是如何实现的 [英] How is iPhone Contact app's detail View implemented

查看:18
本文介绍了iPhone Contact 应用的详细视图是如何实现的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个类似于 Apple 自己的联系人应用程序的详细视图的视图,其中显示姓名、电话号码、便笺等及其编辑模式.

I would like to implement a view similar to the detail view of Apple's own Contacts app where it displays the name, phone number, note, etc. and its Edit mode.

你能剖析整个视图是如何完成的吗?该视图是使用 UITableView 还是 UIScrollView 完成的?

Can you dissect how the whole view is done? Is that view done with a UITableView or a UIScrollView?

推荐答案

联系人详细信息屏幕实际上很容易模仿.

The contact details screen is actually quite simple to mimic.

从 UITableView 开始,并为其提供 UITableViewDataSource 和 UITableViewDelegate.您需要为要呈现的所有数据提供部分.这意味着 1 个用于自定义页眉,1 个用于自定义页脚(按钮/操作),大约 6 个部分用于数据(一个部分用于电话号码,另一个用于电子邮件地址,等等)

Start with a UITableView and provide it with a UITableViewDataSource and UITableViewDelegate. You'll need to provide sections for all the data you want to present. This means 1 for the custom header, 1 for the custom footer (buttons / actions), and approximately 6 or so sections for the data (one section for phone numbers, another for e-mail addresses, and so on)

在每个部分的内部,需要从数据源中提供一些行来指示该部分有多少数据.对于每一行,一个 UITableViewCell 可用于显示实际的联系人数据(传真标签/传真号码值等).如果你愿意,你可以变得花哨,但似乎没有必要.对于铃声之类的内容,您需要指定披露指示符.

Inside of each section, a number of rows need to be provided from your datasource to indicate how much data there is for that section. For each row, a UITableViewCell can be used to display the actual contact data (fax label / fax number value, etc). You can get fancy if you like, but there doesn't seem to be a need. For things like ringtone you'll need to specify a disclosure indicator.

对于页眉,您需要一个 UIImageView 和一个 UILabel,对于页脚,您需要几个 UIButton.您可以在 InterfaceBuilder 中创建 UITableViewCell 的子项,其中包含这些视图,并像其他任何东西一样将其连接起来.您可以使用 NSBundle 从其他尚未加载的 xib 加载视图.

For the header you'll need a UIImageView and a UILabel, for the footer you'll need a few UIButtons. You can create a child of UITableViewCell in InterfaceBuilder with these views inside of it and wire it up like anything else. You can use NSBundle to load views from other xibs that are not already loaded.

另一种方法是在运行时动态生成 UI 小部件,无需 xib.这完全取决于您更愿意管理什么(代码或 xibs),在我看来,无论哪种方式都需要付出相同的努力.我强烈建议通读 表视图编程指南如果你还没有.

An alternative is to dynamically generate the UI widgets at runtime with no xibs. It all depends on what you would rather manage (code or xibs), to me it seems about the same amount of effort either way. I highly recommend reading through the table view programming guide if you haven't already.

这篇关于iPhone Contact 应用的详细视图是如何实现的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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