UI の更新にもしばらく時間がかかります (次のサイクルで)。それを試してください:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
if (tableView == self.localityTableView){
[self.multipleSearchView setHidden:TRUE];
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self closestStation:locality.latitude :locality.longitude];
});
}
}
- (void) closestStation :(float) latitude :(float) longitude{
// SQLite query here to find the closest places
if (self.places.count == 0){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Results"
message:@"No results match your
search. try with other criteria"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
else {
[self displayAnnotations];
}
}
-(void) displayAnnotations{
NSMutableArray *annotations = [[NSMutableArray alloc] init];
for (Station *item in self.places)
{
PlaceAnnotation *annotation = [[PlaceAnnotation alloc] init];
annotation.coordinate = item.coordinate;
annotation.title = item.stationName;
annotation.subtitle = item.address1;
annotation.station = item;
[annotations addObject:annotation];
}
if (annotations.count > 0){
[self.mapView addAnnotations:annotations];
}
}