我已经使用了TTTableViewController的例子来显示一个数组,它可以包含可变数量的行/图像/文本。随着给出的例子,对象的列表是硬编码的初始化,如果视图控制器中,例如:TTTableViewController用对象变量数组填充dataSource
self.dataSource = [TTSectionedDataSource dataSourceWithObjects:
@"Static Text",
[TTTableTextItem itemWithText:@"TTTableItem"],
[TTTableCaptionItem itemWithText:@"TTTableCaptionItem" caption:@"Text"],
[TTTableSubtextItem itemWithText:@"TTTableSubtextItem" caption:kLoremIpsum],
nil];
我想不显示线如果内容(我从另一个变量得到的,让我们在上面的例子中说kLoremIpsum
)是空的。为此,我尝试过:
NSMutableArray * myListOfRows;
myListOfRows = [NSMutableArray arrayWithObjects:
@"Static Text",
[TTTableTextItem itemWithText:@"TTTableItem"],
[TTTableCaptionItem itemWithText:@"TTTableCaptionItem" caption:@"Text"],
nil];
if(kLoremIpsum != nil) {
[myListOfRows addObject:[TTTableSubtextItem
itemWithText:@"TTTableSubtextItem"
caption:kLoremIpsum]];
}
self.dataSource = [TTSectionedDataSource dataSourceWithObjects:
myListOfRows,
nil];
但它不起作用,我的TTTableView保持完全空白。我可以看到表格正在处理我期望的对象数量。为什么这段代码不起作用?
是十分明显的,最终我需要使用dataSourceWithItems来做我想要的2个数组。感谢您答复的质量! – ceyquem 2011-02-02 14:04:19