OGeek|极客世界-中国程序员成长平台

标题: ios - UISearchBardelegate 函数没有响应 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 06:45
标题: ios - UISearchBardelegate 函数没有响应

UISearchBar 委托(delegate)函数仅对 iOS7 iPhone5 没有响应。我的代码中有两个 .xib 文件,一个用于 3.5 英寸屏幕,一个用于 4 英寸屏幕。 对于 3.5 英寸屏幕,它工作正常,但对于 4 英寸屏幕,委托(delegate)函数没有被调用。 你能指导我吗?

- (void)searchBarTextDidBeginEditingUISearchBar *)searchBar {
    [searchBar setShowsCancelButton:YES animated:YES];
    [self keyboardWillShow];
}

- (void)searchBarCancelButtonClickedUISearchBar *)searchBar {
    [self keyboardWillHide];
    searchBar.text=@"";

    [searchBar setShowsCancelButton:NO animated:YES];
    [searchBar resignFirstResponder];
}

- (void)searchBarTextDidBeginEditingUISearchBar *)searchBar 

调用了这个函数,但是 searchBarCancelButtonClicked 不起作用。



Best Answer-推荐答案


我有一些建议给你:

1) 首先检查你的 iPhone5 的 .xib 文件是否连接到 UISearchBar 的委托(delegate)?

2) 您可以为 3.5 英寸和 4 英寸使用一个 .xib 文件,并通过自动调整大小使此 .xib 与 iPhone 4 和 5 兼容。

希望这些点可以解决您的问题。

关于ios - UISearchBardelegate 函数没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21983541/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4