2012-09-25 2 views
0

UISearchDisplayController으로 힘든 시간을 보내고 있습니다. 내 시나리오에서는 UIView navgation 컨트롤러에 밀어 넣었습니다. UIView에는 UITableViewUIToolbar이 있습니다. UITableView에서 나는 UISearchDisplayController을 사용하고 있습니다.UISearchDisplayController의 결과에 도구 모음 추가

<img></img>

도구 모음 단추를 검색에 추가 필터 옵션을 추가하는 데 사용됩니다. 내 문제는 내가 밖으로 찾을 수 없다는 것입니다, UISearchDisplayController의 결과 테이블보기의 하단에 도구 모음을 추가하는 방법.

enter image description here

결과에 도구 모음을 추가로 이동하는 방법은 무엇입니까?

답변

0

마침내 문제를 해결할 수있었습니다.

대신 UISearchDisplayController를 사용하여 UISearchBar를 내 UITableView에 추가하고 UISearchDisplayController의 동작을 UISearchBarDelegate 메서드로 복제합니다. 사람이 여전히 UISearchDisplayController (청소기 아마)를 사용하여이 문제를 해결하는 방법을 궁금 있다면 검색이 활성화되어있는 동안

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText 
{ 
    [self setSearchText:searchText]; 
    [self filterCards]; 
} 

- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope 
{ 
    [self setScopeIndex:selectedScope]; 
    [self filterCards]; 
} 

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar 
{ 
    // Move searchbar to table view 
    [self.chapterSearchBar removeFromSuperview]; 
    [self.chapterTableView addSubview:[self chapterSearchBar]]; 

    // Show navigation controller 
    [self.navigationController setNavigationBarHidden:NO animated:YES]; 

    // Hide scope bar an resize 
    [searchBar setShowsScopeBar:NO]; 
    [searchBar sizeToFit]; 

    // Hide cancel button 
    [searchBar setShowsCancelButton:NO animated:YES]; 

    // Resize table view 
    CGRect tableViewRect = [self.chapterTableView frame];  
    tableViewRect.origin.y = 0; 
    [self.chapterTableView setFrame:tableViewRect]; 

    // Hide keyboard 
    [searchBar resignFirstResponder]; 
    [self setSearchText:@""]; 
    [self filterCards]; 
} 

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar 
{ 
    [searchBar resignFirstResponder]; 
} 

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar 
{ 
    // Move searchbar to controller view 
    [self.chapterSearchBar removeFromSuperview]; 
    [self.view addSubview:[self chapterSearchBar]]; 

    // Hide navigation controller 
    [self.navigationController setNavigationBarHidden:YES animated:YES]; 

    // Show scope bar an resize 
    [searchBar setShowsScopeBar:YES]; 
    [searchBar sizeToFit]; 

    // Show cancel button 
    [searchBar setShowsCancelButton:YES animated:YES]; 

    // Resize table view 
    CGRect tableViewRect = [self.chapterTableView frame];  
    tableViewRect.origin.y = 44; 
    [self.chapterTableView setFrame:tableViewRect]; 

    return YES; 
} 
0

, 단순히보기 컨트롤러의 toolbarItems에 도구 모음의 항목을 설정 :

self.navigationController.toolbarHidden = NO; 
self.toolbarItems = optionsToolbar.items; 

UISearchDisplayControllertoolbarItems에 따라보기 컨트롤러의 도구 모음을 유지하므로 이미 완료되었을 수 있습니다. 도구 모음이 검색 중에 만 사용되는 경우 유용 할 수 있습니다.