2012-07-04 32 views
0

我使得像文本字段搜索。UISearchBarDisplayController不显示我的键盘

在我所先创建文本字段,并添加新的UISearchViewController

现在我已经设定

- (void)textFieldDidBeginEditing:(UITextField *)textField 
{ 
     [textField resignFirstResponder]; 
    self.searchDisplayController.searchBar.hidden = FALSE; 
    [self.searchDisplayController.searchBar becomeFirstResponder]; 
    [self.searchDisplayController setActive:YES animated:NO]; 
} 

但我只看到搜索显示控制器和黑色的背景与出键盘

当我直接按搜索栏它显示键盘

我该怎么做显示键盘在UISearchBarControll呃从上述方法

编辑

请此行是要制造问题从这里http://sourceforge.net/projects/locationdemo/files/LocationDemo.zip/download

回答

0

最后我有我的答案,要与每一个

- (void)textFieldDidBeginEditing:(UITextField *)textField 
{ 
     [textField resignFirstResponder]; 
     NSTimer *theTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(keyboardWasShown:) userInfo:nil repeats:NO]; 
} 

- (void)keyboardWasShown:(NSNotification *)notification 
{ 
    [self.searchDisplayController.searchBar becomeFirstResponder]; 
    self.searchDisplayController.searchBar.hidden = FALSE; 
    CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; 
    CGRect aRect = self.view.frame; 
    aRect.size.height -= keyboardSize.height; 
} 
0

下载我的代码:

[textField resignFirstResponder]; 

为什么会在那里。如果你想显示键盘。在这一点上你不应该这么叫。这将消除或隐藏键盘?

那你打电话给[textField becomeFirstResponder]?

你也可以使用这个UISearchBar,而不是尝试写你自己的。

+0

嘿感谢答复份额,但它不是工作.. – Hiren

+0

见我的编辑以上 –

+0

看我的代码PLZ – Hiren