简体   繁体   中英

UITableView reloaddata and the tableview is empty

There is a navigationViewController and it's the subclass of UITableViewController

@interface TodoViewController : UITableViewController

The rightBarButtonItem is called "Reload" and it will can the function to reload data from the

WebService:

    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Reload" 
                                                                      style:UIBarButtonItemStyleBordered 
                                                                     target:self 
                                                                     action:@selector(reloadTableData)];
rightBarButtonItem.tintColor = [UIColor colorWithRed:0.41176f green:0.41176f blue:0.41176f alpha:1.0];    
self.navigationItem.rightBarButtonItem = rightBarButtonItem;

and there is my reload function:

- (void)reloadTableData
{
    [self.allTodoArray removeAllObjects];
    self.pageIndex = 1;
    [self getTodoList:self.pageIndex sortTpye:self.sortType];

    [self.tableView reloadData];
}

The getTodoList() function will return the new data from the remote WebService, and the

value is not nil.

My question is : when I click the reload button to request the new data of this UITableView

the tableView is empty... I dont know how to make it OK!

Help me with this, thank you in advance!

You will need to reload the table view data asynchronously. Create a callback or block to reload the tableview when the WebService api call completes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM