2011-02-17 2 views
1

여기에 질문이 있습니다. 사용자가 행 중 하나를 선택할 때마다 해당 메서드 searchBarCancelButtonClicked를 호출하여 [searchBar resignFirstResponder]; 내가 어떻게 할 수 있니?검색 호출 다른 방법으로 BarCancelButtonClicked 메서드

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

    NSString *KeyCor; 
    NSString *YKeyCor; 
    NSString *DesName; 
    Service *aService; 

    aService = [appDelegate.blocks objectAtIndex:indexPath.row]; 

    KeyCor=[aService xcoordinate]; 
    YKeyCor=[aService ycoordinate]; 
    DesName=[aService name]; 

    Service *s = [[Service alloc] initWithLat:YKeyCor andLong:KeyCor andName:DesName]; 
    MapViewController *mvController = (MapViewController *)[MapViewController sharedInstance]; 
    mvController.view.alpha = 1; 

    //[self.navigationController pushViewController:mvController animated:YES]; 
    [mvController showMarkingOnMap:s]; 


    //self.searchBarCancelButtonCLicked; <--- fail 

    /// 
} 

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar 

{ 
    sBar.showsCancelButton = NO; 
    [tableData removeAllObjects]; 
    [tableData addObjectsFromArray:dataSource]; 

    [searchBar resignFirstResponder]; 

    sBar.text = @""; 

    [myTableView removeFromSuperview]; 

} 

답변

2
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    ... 

    [self searchBarCancelButtonClicked:whateverYouNamedYourSearchbar]; 
} 
관련 문제