4


我正在尝试UITableView从 Sqlite 获取部分和索引(我使用 FMDB 作为包装器)。
我似乎不知道从哪里开始。
我可以从数据库中读取信息并将其存储在NSMutableArray.

我尝试了以下站点,但他使用的是 plist。 http://www.icodeblog.com/2010/12/10/implementing-uitableview-sections-from-an-nsarray-of-nsdictionary-objects/

任何意见,将不胜感激。

4

1 回答 1

0

你需要制作一个数组数组。主数组将代表 tableview 部分,而内部数组将是部分的内容。

numberOfSectionsInTableView看跌期权

return [mainArray count];

cellForRowAtIndexPath

NSMutableArray *tempDict = [mainArray objectAtIndex:indexPath.section];
NSArray *tempArray = [tempDict objectAtIndex:indexPath.row];
cell.textLabel.text = [NSString stringWithFormat:@"%@", [tempArray valueForKey:@"name"]];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", [tempArray valueForKey:@"detail"]];
return cell;

psthe 最后一个对象在我的情况下是一个 NSDictionary,这就是我使用valueForKey. 祝你好运!

于 2012-01-20T02:26:32.120 回答