iphone表服务器输出与单元格标题和副标题?

时间:2011-11-25 23:16:58

标签: iphone objective-c xcode

我目前有一个应用程序,它从网页上读取一行,如下所示:

1/2/3/4/5/

然后它输出五个单元格中表格中的每个数字。

但是,我想输出一些额外的信息以及数字,以便我的表格单元格有一个标题和一个subtile。

Title: 1
Subtitle: Number one
Title: 2
Subtile: Number two

etc.

但我不知道在哪里存储字幕文本 - 我是否需要从网页上读取新行,或者是否可以将标题和副标题存储在同一行中,例如:

1, Number one/2, Number two/3, Number three/

然后告诉应用将第一项用作标题,将第二项用作副标题?

1 个答案:

答案 0 :(得分:0)

cellForRowAtIndexPath中,当您创建新单元格时,将该单元格的detailText定义为Subtitle: Number one,并对单元格样式进行更改,如下所示:

if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}

每当您为标题:1 创建单元格时,您只需要为单元格值定义detailText.text属性。如果UITableViewCellStyleSubtitle这不起作用,请尝试使用UITableViewCell的不同样式。