I have created a view controller, and added a table view as a subview to display data I fetch asynchronously from a web service. Initially the view displays an empty table. After the data is fetched, it is sorted, then stored in an array which holds the data for the table view. I call reloadData on the tableView at that point, and the data is displayed correctly. At this moment in time, the table view acts as it should (scrolling works as expected). However, as soon as I click on a cell, which takes me to a detail view controller (presented modally), when I return the table view has scrolled to the top, and scrolling is disabled (content still bounces however). The data is still there, if I drag up on the table cells, more are shown but snap back off screen once I let go.
Further complicating the issue is my custom split-view controller for changing the content displayed in the table view. It shows and hides itself with gestures, pressing an object in it will refetch the data in the main table view. At the point where the service finished loading the data and the table data has been refreshed, the table scrolls again as would be expected.
The app only supports iOS 6.0 and up for phone device types.
Here is some code that retrieves the data from the web service:
- (BOOL) getPatientVisits {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSDictionary *response = [[HMWebServiceFacade defaultFacade] getVisitListingForPatientId:appDelegate.selectedPatientId withUserCredential:appDelegate.usernamePasswordHash];
dispatch_async(dispatch_get_main_queue(), ^{
if ([[response objectForKey:@"status"] isEqualToString:@"OK"])
{
patientVisits = [[HMCommonUtils commonUtils] sortedArrayOfVisits:[response objectForKey:@"visits"]];
}
else if ([response objectForKey:@"RequestError"])
{
[[HMCommonActions standardActions] displayErrorAlertMessage:[response objectForKey:@"RequestError"]];
}
else
{
[[HMCommonActions standardActions] displayErrorAlertMessage:@"There were no visits for your loved one." withTitle:@"Sorry"];
patientVisits = nil;
}
[visitsTable reloadData];
[self viewWillAppear:YES];
});
});
return false;
}
In viewDidLoad I call [self getPatientVisits]; as well as in the callback function for any of clicked objects in the split-view.
You can set the
scrollEnabledproperty of thetableViewin theviewDidLoadmethod of the View.