如何在表格视图中显示数组值
Posted
技术标签:
【中文标题】如何在表格视图中显示数组值【英文标题】:How to display the array values in table view 【发布时间】:2012-05-10 06:55:18 【问题描述】:我有一个从字典值中获取数据的内容数组,现在我需要在表格视图单元格中显示数组内容,但它没有显示正确的数据。
这里是源代码
for (int i = 0; i < [self.illArray count]; i++)
NSMutableDictionary *lDict = [self.illArray objectAtIndex:i];
NSString *lTitle = [lDict objectForKey:@"title"];
if ([lTitle rangeOfString:@"Symptoms"].length > 0)
[m_cIllResultArray addObject:lDict];
for (int i = 0; i < [m_cIllResultArray count]; i++)
sDict = [m_cIllResultArray objectAtIndex:i];
NSString *sDetail = [sDict objectForKey:@"SYMPTOMS"];
[sDict setValue:sDetail forKey:@"details"];
NSLog(@"ARRAY VALUES1:-%@", [sDict valueForKey:@"details"]);
数据格式为:
ARRAY VALUES : (
SYMPTOMS = (
"Abdominal pain",
Constipation,
Diarrhea,
"Hard to breathe"
);
independentItem = 0;
module = 117;
seqCounter = 101;
sequence = 10010;
session = 101;
title = "Low Alert: Symptoms";
,
SYMPTOMS = (
"Abdominal pain",
Constipation,
Diarrhea
);
independentItem = 0;
module = 117;
seqCounter = 102;
sequence = 10022;
session = 101;
title = "High Alert : Symptoms";
,
SYMPTOMS = (
"Abdominal pain",
Dehydration,
"Elevated temperature (>100 degrees)"
);
independentItem = 0;
module = 117;
seqCounter = 101;
sequence = 10040;
session = 101;
title = "Low Alert: Symptoms";
我需要在表格视图的内容中显示症状键
提前致谢
【问题讨论】:
看看它的样子[点击这个链接](***.com/questions/10332507/…),它会对你有所帮助。 【参考方案1】:制作自定义表格视图,例如闪烁单元格或您可以使用的任何其他内容,如果可能,制作 plist 并传输数据,您可以更好地重复使用它如果您以这种方式找到任何查询,我会通过这种方式得到结果,告诉我我会发送你演示代码.....希望你能以这种方式得到你的解决方案
【讨论】:
【参考方案2】:制作一个自定义表格视图单元格并将所有数据放入其中。阅读这些教程了解更多详情
http://www.galloway.me.uk/tutorials/custom-uitableviewcell/
http://www.e-string.com/content/custom-uitableviewcells-interface-builder
【讨论】:
【参考方案3】:试试这个..我认为它有效..
for (int i = 0; i < [self.illArray count]; i++)
NSMutableDictionary *lDict = [self.illArray objectAtIndex:i];
NSString *lTitle = [lDict objectForKey:@"title"];
if ([lTitle rangeOfString:@"Symptoms"].length > 0)
[m_cIllResultArray addObject:[sDict objectForKey:@"SYMPTOMS"]];
NSLog(@"ARRAY VALUES1:-%@", m_cIllResultArray);
【讨论】:
以上是关于如何在表格视图中显示数组值的主要内容,如果未能解决你的问题,请参考以下文章