0

this issue occurs if i forcefully show the scope bar to render 而呈現搜索控制器我設置的showScopeBar屬性爲隱藏或顯示範圍欄的UISearchBar問題,當scopebar是隱藏和顯示

- (void)willPresentSearchController:(UISearchController *)searchController { 
    // do something before the search controller is presented 
    NSMutableArray *scopeArray = @[@"All"].mutableCopy; 
    UISearchBar *searchBar =_searchController.searchBar; 
    if (![labelDepartmentSelection.text isEqualToString:@"Department"]) { 
     [scopeArray addObject:@"Department"]; 
    } 
    if (![labelJobSelection.text isEqualToString:@"Job"]) { 
     [scopeArray addObject:@"Job"]; 
    } 
    searchBar.scopeButtonTitles = scopeArray; 

    searchBar.showsScopeBar = scopeArray.count>1; 
    [searchBar layoutIfNeeded]; 
    NSArray *subviews = searchBar.subviews; 
    if([[UIDevice currentDevice].systemVersion floatValue]>=7.0) { 
     //Get search bar with scope bar to reappear after search keyboard is dismissed 
     UIView *scopeBar = [subviews.firstObject subviews].firstObject; 
     [scopeBar setHidden:NO]; 
     CGRect frame = scopeBar.frame; 
     frame.origin.y = frame.origin.y = 64.0; 
     scopeBar.frame = frame; 
    } 
    [searchBar layoutSubviews]; 

    [searchBar sizeToFit]; 
    [serviceOptionTableView setContentInset:UIEdgeInsetsMake(scopeArray.count>1?44:0, 0, 0, 0)]; 

    serviceOptionTableView.tableHeaderView = searchController.searchBar; 
} 

,當我簡單地隱藏和顯示範圍棒臺範圍標題我想它giet扭曲 這裏是這個

- (void)willPresentSearchController:(UISearchController *)searchController { 
    // do something before the search controller is presented 
    NSMutableArray *scopeArray = @\[@"All"\].mutableCopy; 
    UISearchBar *searchBar =_searchController.searchBar; 
    if (!\[labelDepartmentSelection.text isEqualToString:@"Department"\]) { 
     \[scopeArray addObject:@"Department"\]; 
    } 
    if (!\[labelJobSelection.text isEqualToString:@"Job"\]) { 
     \[scopeArray addObject:@"Job"\]; 
    } 
    searchBar.scopeButtonTitles = scopeArray; 

    searchBar.showsScopeBar = scopeArray.count>1; 

    \[serviceOptionTableView setContentInset:UIEdgeInsetsMake(scopeArray.count>1?44:0, 0, 0, 0)\]; 

} 

這種情況是區分圖像2

+0

你能解決這個問題嗎? –

+0

實際上,我發現在運行時更新了uisearch欄的範圍正在創建此問題。 –

回答

0

這個問題應該可以解決本身,如果你刪除行:

searchBar.showsScopeBar = scopeArray.count>1; 

設置showScopeBar酒店出於某種原因一個奇怪的效果。刪除它允許默認的動畫行爲沒有任何問題。