2

저는 UISearchBar가있는 tableView를 가지고 있습니다. iOS 4로 업그레이드하기 전에 사용자가 셀을 선택하고 새로운 viewController가 눌려지면 키보드가 테이블에서 왼쪽으로 미끄러졌습니다.iOS 4에서 셀을 선택하면 UISearchBar 키보드가 보이지 않게 슬라이드되지 않습니다.

이제 새보기 상단에 화면에 그대로 둡니다. [mySearchBar resignFirstResponder]를 호출하면; 키보드를 제거 할 수는 있지만 애니메이션이 어색하기 때문에 새로운 뷰가 푸시되고있는 동안 화면 하단에서 미끄러 져 움직입니다.

iOS 4에서 동작이 다른 이유를 알고있는 사람이 있습니까? 키보드를 tableView에 묶어서 새보기를 누르면 화면 밖으로 미끄러지도록 할 수 있습니까?

감사합니다.

편집 : 다음은 몇 가지 추가 정보입니다. 탐색 바 뒤에 uisearchbar가 있습니다. 사용자가 버튼을 누르면 슬라이드 아웃됩니다. 나는 uisearchbar과 같이 추가 탐색 모음 실제로 다음 뷰 (검색 바는하지만), 키보드를 제자리에 유지에 푸시되지 않기 때문에

[self.navigationController.view insertSubview:self.mySearchBar belowSubview:self.navigationController.navigationBar]; 

가 나는 것 같아요.

나는 tableview 뒤에 uiview를 만들고 거기에 검색 바를 추가하려고 시도했지만 UINavigationController와 코드 구조 때문에 작동하지 못했습니다.

답변

1

개인적으로 UISearchDisplayController를 사용하는 검색 표시 줄을 구현하는 것이 좋습니다. 나는 이것이 xCode에서 사용되는 표준 템플릿을 구현하고 모든 응답자를 실제로 부드럽게 처리한다고 생각합니다.

- (void) addSearchBar:(NSString*)placeholder hasScope:(BOOL)aScope { 


    UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero]; 
    [searchBar sizeToFit]; 

    //searchBar.delegate = self; 
    searchBar.placeholder = placeholder; 
    self.tableView.tableHeaderView = searchBar; 

    if (aScope==YES){ 
     searchBar.showsScopeBar = YES; 
     searchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"Flags",@"Listeners",@"Stations",nil];  
    } 




    UISearchDisplayController *searchDC = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]; 

    // The above assigns self.searchDisplayController, but without retaining. 
    // Force the read-only property to be set and retained. 
    [self performSelector:@selector(setSearchDisplayController:) withObject:searchDC]; 

    //searchDC.delegate = self; 
    //searchDC.searchResultsDataSource = self; 
    //searchDC.searchResultsDelegate = self; 

    [searchBar release]; 
    [searchDC release]; 

} 
: 여기

[self addSearchBar:@"enter search keywords here" hasScope:NO] 

권장 코드를 사용하여 당신은 당신의 코드에 복사하고 실행을 시도 할 수있는 방법의 예

관련 문제