从 Dropbox 加载数据时,iOS UITableView 不会显示任何内容

发布于 2025-01-04 04:08:31 字数 1613 浏览 0 评论 0原文

我有一个 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;
    }

I have a UITableView thats supposed to show the contents of a folder from dropbox when it loads. I know its getting the data from dropbox by using log statements. I reload the data in the table after it gets the data from drop box but it still shows nothing. Please help

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

左秋 2025-01-11 04:08:31

您只需要在发出请求时显示 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];
    }

这绝对能解决你的问题。
祝您编码愉快;)

You just need to show ProcessIndicator while you are making request

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

And Hide when u get this method called.

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

This will definitely solve your problem.
Have a happy Coding ;)

南街女流氓 2025-01-11 04:08:31

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

[[self restClient] loadMetadata:@""];

Never mind i got it. This was the correct call to load metadata:

[[self restClient] loadMetadata:@""];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文