关于表视单元的调整

时间:2017-01-31 10:21:24

标签: ios objective-c uitableview dropbox

这里我想显示文件夹或目录的披露指示器:

我的cellForRowAtIndexPath方法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

DropboxCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Dropbox_Cell2"];

DBMetadata *metadata = [filesNames objectAtIndex:indexPath.row];
[cell.btnIcon setTitle:metadata.path forState:UIControlStateDisabled];
[cell.btnIcon addTarget:self action:@selector(btnDownloadPress:) forControlEvents:UIControlEventTouchUpInside];


if (metadata.isDirectory) {
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.btnIcon.hidden = YES;
      NSLog(@"yes");
}else {
    NSLog(@"No");
    cell.accessoryType = UITableViewCellAccessoryNone;
    cell.btnIcon.hidden = NO;
}


NSString *sectionTitle = [newsectionTitles objectAtIndex:indexPath.section];
NSArray *sectionRows = [dict objectForKey:sectionTitle];
NSString *cellName = [sectionRows objectAtIndex:indexPath.row];

//cell.lblTitle.text = metadata.filename;
 cell.lblTitle.text = cellName;
return cell;
}

请参阅图片和帮助。

Rest客户端委托方法,用于加载和操作数据: Rest client delegate method which is used to load and manipulate data

表视图的

numberOfRowsInSection方法: numberOfRowsInSection method of table view

1 个答案:

答案 0 :(得分:0)

由于您返回了多个部分,因此indexPath.row方法更改中的cellForRow取决于部分,因此请尝试处理metadata.isDirectory取决于部分和行而不是仅行,我希望有所帮助你。