2012-02-11 64 views
1

我有一个UITableView应该在加载时显示Dropbox中文件夹的内容。我知道它通过使用日志语句从Dropbox获取数据。在从下拉框中获取数据后,我重新加载表中的数据,但它仍然不显示任何内容。请帮助iOS UITableView在Dropbox加载数据时不会显示任何内容

- (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

没关系我明白了。这是正确的调用加载的元数据:

[[self restClient] loadMetadata:@""]; 
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 
} 

当u得到这种方法称为隐藏。

- (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]; 
    } 

这一定会解决您的问题。 有一个快乐的编码;)

+0

谢谢你的回答,但我从2月以来没有在此工作。我问的是如何从Dropbox加载文件。谢谢。 – Slayter 2013-02-27 21:41:47

相关问题