单击取消时,我想更改 uisearchDisplaycontroller 的宽度。我添加我的代码以供参考...
mySearchBar = [[UISearchBar alloc]init];
[mySearchBar setDelegate:self];
resName_search = [[UISearchDisplayController alloc] initWithSearchBar:mySearchBar contentsController:self];
resName_search.delegate = self;
resName_search.searchResultsDataSource = self;
resName_search.searchResultsDelegate = self;
[self.view addSubview:resName_search.searchBar];
[resName_search.searchBar setFrame:CGRectMake(0.0, barOriginY+79.0, 106.0, 40.0)];
它显示得很好...但是当我搜索项目然后单击取消按钮时...它不会调整大小..
-(BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
btnCuisine.hidden =YES;
btnService.hidden =YES;
imgDropDwn1.hidden =YES;
imgDropDwn2.hidden =YES;
[resName_search.searchBar setShowsCancelButton:YES animated:NO];
[resName_search.searchBar setFrame:CGRectMake(0.0, barOriginY+79.0, 320.0, 40.0)];
return YES;
}
-(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
NSLog(@"size changed 106.0");
[resName_search.searchBar setShowsCancelButton:NO animated:NO];
[resName_search.searchBar setFrame:CGRectMake(0.0, barOriginY+79.0, 106.0, 40.0)];
btnCuisine.hidden =NO;
btnService.hidden =NO;
imgDropDwn1.hidden =NO;
imgDropDwn2.hidden =NO;
}
我还为该问题添加了图片链接,请参考解决我的问题 图片链接