0
而呈現搜索控制器我設置的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
你能解決這個問題嗎? –
實際上,我發現在運行時更新了uisearch欄的範圍正在創建此問題。 –