我正在使用UISearchBar
搜索列表,但當我點擊鍵盤上的搜索按鈕 時,鍵盤不會隱藏。
請幫我解決這個問題。
這裏是我的代碼無法隱藏鍵盤單擊搜索按鈕在UISearchBar
-(void)search:(UISearchBar*)searchbar Text:(NSString*)text
{
[copyListOfItems removeAllObjects];
if([text length] > 0) {
// [ovController.view removeFromSuperview];
searching = YES;
NSString *searchText = searchBar.text;
for(imergencyData *objtrust in aryTrustee)
{
NSRange titleResultsRange = [objtrust.strName rangeOfString:searchText options:NSCaseInsensitiveSearch];
if (titleResultsRange.length > 0)
[copyListOfItems addObject:objtrust];
}
NSLog(@"number of object found %d",copyListOfItems.count);
}
else
{
// [tblTrustee insertSubview:ovController.view aboveSubview:self.parentViewController.view];
[searchbar resignFirstResponder];
searching = NO;
//tblTrustee.scrollEnabled = NO;
}
[tblTrustee reloadData];
}
-(void)searchBarTextDidEndEditing:(UISearchBar *)aSearchBar
{
[aSearchBar resignFirstResponder];
[self.view endEditing:YES];
}
//Method call when type text in search box
-(void)searchBar:(UISearchBar *)theSearchBar textDidChange:(NSString *)searchText {
[self search:theSearchBar Text:searchText];
}
//method call when on search button
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBa{
[searchBa endEditing:YES];
[searchBa resignFirstResponder];
[self search:searchBa Text:searchBar.text];
}
您的問題添加更多描述你的代碼的例子,讓人們將能夠幫助你。 – 2013-05-02 13:35:40