Home Features Docs Blog Support GitHub

tableView refresh issue


(Sachin) #1

I have an which subscribes to an external event, when it receives data it adds it to the table view data source. im trying to refresh the screen when new data is added to the table.
I have tried below 2 approaches to update table in UI and both of them doesnt show latest data on the screen unless i click on the screen somewhere.

        public void updateTable(){
        try {
            if (tableView() != null) {
                NSIndexPath path = NSIndexPath.indexPathForRowInSection(tableDataSource.getListSize() - 1, 0);
                NSArray paths = NSArray.arrayWithObject(path);
                tableView().insertRowsAtIndexPathsWithRowAnimation(paths, UITableViewRowAnimation
                        .Automatic);
            }
           
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Above method was taken from the RSS feed MOE sample
I have also tried to refresh the whole table with

//below code does not refresh the screen unless i click on in
 this.tableView().reloadData();

I’m looking for a working method/code snippet to update my tableview when i add data to it.

Thank you in advance

Sachin


(Sachin) #2

here is the video of the issue. As mentioned earlier, table data gets updated but tableview does not refresh till user clicks on the UI


(Eugene) #3

Check you are calling tableView().reloadData() or tableView().insertRowsAtIndexPathsWithRowAnimation(…) from an UI thread


(Sachin) #4

Hi Eugene,

I’m calling those in the main UI thread.