UISearchBar没有成为第一响应者

时间:2015-01-21 21:08:22

标签: objective-c cocoa-touch uisearchbar

我在应用程序中有一个UISearchBar。最初,它位于页面底部,但我想向上移动。我能够做到这一点,但我现在无法使键盘出现。我没有尝试过这些典型的建议。我的代码应该正常工作。

iOS 8。

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
    //move the search bar up to the correct location eg
    [UIView animateWithDuration:.4
                     animations:^{
                         searchBar.frame = CGRectMake(searchBar.frame.origin.x,
                                                      0,
                                                      searchBar.frame.size.width,
                                                      searchBar.frame.size.height);
                     }
                     completion:^(BOOL finished){
                         [self.searchDisplayController setActive: YES animated: YES];
                         self.searchDisplayController.searchBar.hidden = NO;
                         [self.searchDisplayController.searchBar becomeFirstResponder];



                     }];
                       [self.searchBar becomeFirstResponder];
    return NO;
}

0 个答案:

没有答案