- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个带有 uisearchbar 和 uitable 的简单 View Controller 。我的问题是,当点击搜索栏时,我看到委托(delegate)函数 searchBarShouldBeginEditing 被调用但不是 searchBarTextDidBeginEditing(并且由于键盘未打开并且搜索不可编辑)
我尝试实现委托(delegate)函数 searchBarShouldBeginEditing 返回 YES,将搜索栏设置为第一响应者,但我无法调用 searchBarTextDidBeginEditing...
知道会发生什么吗??
部分代码:
Controller .h
@interface ViewController : UIViewController <UISearchBarDelegate>
{
UISearchBar * searchbar;
}
@property (nonatomic, retain) IBOutlet UISearchBar* searchbar;
@end
Controller .m
@synthesize searchbar;
- (BOOL)respondsToSelector:(SEL)sel {
NSLog(@"Queried about %@", NSStringFromSelector(sel));
return [super respondsToSelector:sel];
}
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
NSLog(@"searchBarShouldBeginEditing -Are we getting here??");
return YES;
}
-(void) searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
NSLog(@"searchBarTextDidBeginEditing -Are we getting here??");
}
当然,我的类(class)有更多的代码(这肯定会以某种方式影响搜索栏)但是如果有人遇到与搜索栏类似的问题,将非常感谢它的响应;)
我尝试只使用搜索栏制作简单的应用程序,显然它有效...
编辑:
稍微测试一下,我发现它与 uisearchbar 无关,因为我添加了一个 TextField 得到了相同的结果(只是调用了 textFieldShouldStartEditing 委托(delegate)函数)
应用程序在 UITabBar Controller 中包含所有 View Controller ,但我不认为这会导致所有这些困惑...
编辑2:
非常奇怪的行为:将 IBAction 函数设置为 UITextfield 的 TouchDown 事件完美无缺,但将 IBAction 函数设置为 EditingDidBegin 永远不会被触发...
为什么不能调用此事件??
最佳答案
是否设置了委托(delegate)属性?
searchbar.delegate = self;
关于ios - UISearch 栏不调用 searchBarTextDidBeginEditing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8007454/
我正在从解析中查询,当我尝试使用搜索栏进行搜索时,它返回“无结果”。我试图弄清楚我在显示对象时做错了什么,因为它确实在 NSLog 中显示它找到了对象。 我的 viewDidLoad: - (v
当我开始编辑搜索栏内容时,我试图扩展 UISearchBar 的高度。我正在 UISearchBarController 中执行以下代码。 func searchBarTextDidBeginEdit
我有一个预填充“当前位置”的 UISearch 栏,但是当用户开始输入时,我想删除预填充的文本,只显示用户正在输入的文本。我已经尝试过了,但似乎无法正常工作: -(void)searchBar:(UI
我正在使用 uisearchbar、tableview 和 JSON Web 服务使用以下代码进行搜索。当前的问题是,尽管应用程序正在搜索并在表格 View 中呈现数据,但它是在搜索栏中发生每个文本更
我有一个带有 uisearchbar 和 uitable 的简单 View Controller 。我的问题是,当点击搜索栏时,我看到委托(delegate)函数 searchBarShouldBeg
在我的 Storyboard上,我添加了一个 UISearchBar,并在其下方添加了一个表格 View 。在 iPhone 8 上,我看到 UISearchBar 位于导航栏/标题的正下方;在 iP
用于呈现 SearchController 的代码: searchController = UISearchController(searchResultsController:viewcontrol
我需要实现搜索历史记录。所以我想做的是在尚未输入文本时在搜索显示 Controller 中显示历史记录。 我实现了这个: -(void)searchDisplayControllerDidBeginS
我试图在 swift 4 中使搜索栏透明。 这是我的代码 let searchBar = UISearchBar() searchBar.sizeToFit() search
我只是想知道在 iOS 应用程序中是否可以将 UISearchBar 或 UISearchDisplayController 设置为 UIActionSheet? 最佳答案 UIActionSheet
我在一个社交网络上工作,我希望用户名只使用小写,在用户名文本字段中,我如何让键盘不允许大写字母(我可以在事后强制 textfield.text 字母变成小写但我真的不想那样做)我还需要它为 UISea
我正在尝试在我的应用程序中配置我的搜索栏。我有一个包含 NSObject 实例的数组,并尝试使用搜索选项来查找(这个 NSObjects 的)合适的属性。其实,我可以找到它。我的问题是,我只能在 UI
我是一名优秀的程序员,十分优秀!