【发布时间】:2015-08-04 06:16:50
【问题描述】:
我尝试了多种方法,我不知道。谁能告诉我实现这一点的方法。
json 值:
dict=@{
@"car":@[@"hatchbag",@"sedan",@"suv"],
@"waterpurifier":@[@"one litre",@"two litre",@"three litre"]
};
我的代码:
subArray=[dict objectforkey:@"car"];
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section
NSLog(@"expand section %d",expandSection);
if (expandSection == section) {
return [subArray count]+1;
}
else
return 1;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
// Configure the cell...
if (indexPath.row == 0) {
cell.textLabel.text = [arrPlayList objectAtIndex:indexPath.section];
cell.imageView.image = [UIImage imageNamed:@"twitter_icon_29x29.png"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
说明: 我已将 json 值存储到单独的数组中,但我不清楚如何分隔单元格,如何将这些数据显示到单独的单元格朋友中。
Header:
car
->hatchbag
->sedan
->suv
waterpurifier
->0ne litre
->two litre
->three litre
我怎样才能像这样在表格视图中显示数据。
【问题讨论】:
标签: ios objective-c uitableview nsdictionary nsindexpath