如何iPhone联系人应用程序的细节视图实现 [英] How is iPhone Contact app's detail View implemented

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

问题描述

我想实现一个类似于苹果自己的联系人应用程序的详细视图,其中显示名称,电话号码,注释等及其编辑模式。



你能剖析整个视图是怎么做的吗?这个视图是用UITableView还是UIScrollView完成的?

解决方案

联系方式屏幕实际上很容易模仿。 >

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



在每个部分中,需要从数据源中提供多个行,以指示该部分有多少数据。对于每一行,可以使用UITableViewCell显示实际的联系人数据(传真标签/传真号码值等)。你可以得到幻想,如果你喜欢,但似乎没有需要。对于铃声等事件,您需要指定一个公开指示符。



对于标题,您需要一个UIImageView和一个UILabel,对于页脚,您需要一个几个UIButtons。你可以在InterfaceBuilder中创建一个UITableViewCell的子对象,并在其中包含这些视图,并像其他任何一样连接。您可以使用NSBundle从其他尚未加载的xib加载视图。



另一种方法是在运行时动态生成没有xibs的UI小部件。这一切都取决于你想要管理什么(代码或xibs),对我来说似乎是相同的努力量。我强烈建议您阅读表格视图编程指南(如果您还没有)。


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.

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.

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)

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.

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.

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联系人应用程序的细节视图实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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