Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS UISearchBar:Set-showsScopeBar=YES&ScopeButtonTiles不是nil,但scopeBar不显示_Ios_Iphone_Objective C_Uisearchbar - Fatal编程技术网

iOS UISearchBar:Set-showsScopeBar=YES&ScopeButtonTiles不是nil,但scopeBar不显示

iOS UISearchBar:Set-showsScopeBar=YES&ScopeButtonTiles不是nil,但scopeBar不显示,ios,iphone,objective-c,uisearchbar,Ios,Iphone,Objective C,Uisearchbar,我快疯了!这是我的问题。我想在开始搜索时显示UISearchBar.ScopeBar,并在搜索后隐藏它。我在中找到了一个解决方案帖子 但这对我不起作用。 这是我的密码: self.friendSearchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"Phone",@"Name", nil]; self.friendSearchBar.selectedScopeButtonIndex = 0; self.friendSea

我快疯了!这是我的问题。我想在开始搜索时显示UISearchBar.ScopeBar,并在搜索后隐藏它。我在中找到了一个解决方案帖子 但这对我不起作用。 这是我的密码:

   self.friendSearchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"Phone",@"Name", nil];
   self.friendSearchBar.selectedScopeButtonIndex = 0;
   self.friendSearchBar.showsScopeBar = YES;

您好,要在搜索后让搜索栏消失,您需要实现这一点

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
YourScopeGoesHere scopeKey = controller.searchBar.selectedScopeButtonIndex;
[self searchForText:searchString scope:scopeKey];
return YES;
}

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption
{
NSString *searchString = controller.searchBar.text;
[self searchForText:searchString scope:searchOption];
return YES;
}