我有一个UITableView,它应该在加载时从dropbox显示文件夹的内容。我知道它通过使用日志语句从dropbox获取数据。我从drop框中获取数据后重新加载表中的数据,但它仍然没有显示任何内容。请帮忙
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
uploadFileButton = [[UIBarButtonItem alloc] initWithTitle:@"Upload" style:UIBarButtonItemStyleBordered target:self action:@selector(uploadFile:)];
self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.navigationItem.leftBarButtonItem = uploadFileButton;
self.title = @"DropBox";
[[self restClient] loadMetadata:@"/"];
}
- (void)restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata {
for (DBMetadata *file in metadata.contents) {
NSLog(@"\t%@", file.filename);
[dropBoxArray addObject:file.filename];
}
NSLog(@"%@", dropBoxArray);
[self.tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [dropBoxArray objectAtIndex:indexPath.row];
NSLog(@"%@", cell.textLabel.text);
return cell;
}
答案 0 :(得分:1)
您只需要在提出请求时显示ProcessIndicator
- (void)viewDidLoad
{
[super viewDidLoad];
uploadFileButton = [[UIBarButtonItem alloc] initWithTitle:@"Upload" style:UIBarButtonItemStyleBordered target:self action:@selector(uploadFile:)];
self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.navigationItem.leftBarButtonItem = uploadFileButton;
self.title = @"DropBox";
[[self restClient] loadMetadata:@"/"];
[self showProcessIndicator]; //Your code for showing ProcessIndicator
}
当你调用这个方法时隐藏。
- (void)restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata {
for (DBMetadata *file in metadata.contents) {
NSLog(@"\t%@", file.filename);
[dropBoxArray addObject:file.filename];
}
NSLog(@"%@", dropBoxArray);
[self.tableView reloadData];
[self hideProcessIndicator];
}
这肯定会解决您的问题。 有一个快乐的编码;)
答案 1 :(得分:0)
没关系,我明白了。这是加载元数据的正确调用:
[[self restClient] loadMetadata:@""];