【发布时间】:2011-03-18 11:37:23
【问题描述】:
我正在尝试获取一个表格视图来将数组中的数据拆分为多个部分...
我对此很陌生,但下面是我的代码 sn-p
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(section == 0)
{
contentArray = [[NSArray arrayWithObjects:@"Send SMS", @"Reports", nil] retain];
}
if(section == 1)
{
contentArray = [[NSArray arrayWithObjects:@"Accounts", nil] retain];
}
return [contentArray count];
}
我已成功将数据拆分为 2 个部分,但在填充行时它只是在两个部分中重复第一个内容数组。
谁能帮忙...
谢谢
【问题讨论】:
-
你能贴出 cellForRowAtIndexPath 的代码
-
在您的示例代码中,您将有很多内存泄漏。例如,最好在 viewDidLoad 中创建数组。因为您将需要通过几种方法访问数组。请参阅@fluchtpunkt 的答案。
标签: iphone objective-c cocoa-touch ios ios4