在搜索栏iOS上选择结果后如何防止清除搜索文本?

时间:2015-12-29 10:17:13

标签: ios objective-c uisearchbar

我有一个搜索栏,我正在使用它搜索位置。当我搜索并选择一个位置时,搜索栏文本将被清空。是否可以将所选文本保留在搜索栏上。这就是我试过的,

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    SPGooglePlacesAutocompletePlace *place = [self placeAtIndexPath:indexPath];
    [place resolveToPlacemark:^(CLPlacemark *placemark, NSString *addressString, NSError *error) {
        if (error) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Could not map selected Place"
                                                        message:error.localizedDescription
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil, nil];
            [alert show];
        } else if (placemark) {
            searchedString = place.name;
            [self.parent showHUD];
            [self.searchDisplayController setActive:NO];
            [self.searchDisplayController.searchResultsTableView deselectRowAtIndexPath:indexPath animated:NO];
            [self retrieveSearchResults:1 place:[place name]];
            [self.searchView setText:[place name]];
        }
    }];
}

我该如何解决这个问题?

0 个答案:

没有答案