草庐IT

UIsearchBar

全部标签

ios - 将 UISearchBar 与 TableView Controller 一起使用并转到另一个 View 时显示问题

自iOS8以来,我在设置TableView/UISearchBar时遇到了一个奇怪的问题,想知道是否其他人也遇到过类似的问题,或者可以指出我可能做错了什么(如果有的话)。大致情况:我有一个UITableViewController,里面有一个UISearchBar,在应用程序的Storyboard中设置表格View有一个自定义单元格,也是在Storyboard中设置的选择表格行会触发到另一个View的segue执行搜索,点击搜索结果中的一行以转到另一个View,然后再次导航回来,会触发各种问题。“问题”是如果我按如下方式实现cellForRowAtIndexPath:-(UITable

ios - UISearch 栏不调用 searchBarTextDidBeginEditing

我有一个带有uisearchbar和uitable的简单ViewController。我的问题是,当点击搜索栏时,我看到委托(delegate)函数searchBarShouldBeginEditing被调用但不是searchBarTextDidBeginEditing(并且由于键盘未打开并且搜索不可编辑)我尝试实现委托(delegate)函数searchBarShouldBeginEditing返回YES,将搜索栏设置为第一响应者,但我无法调用searchBarTextDidBeginEditing...知道会发生什么吗??部分代码:Controller.h@interfaceVie

iOS:UISearchBar 中的 UIActivityIndi​​cator

是否可以在搜索时在UISearchBar中显示一个UIActivityIndi​​cator? 最佳答案 针对iOS13的更新。您可以在Swift4+中使用以下扩展。用法:显示事件:searchBar.isLoading=true隐藏事件:searchBar.isLoading=falseUISearchBar扩展extensionUISearchBar{publicvartextField:UITextField?{if#available(iOS13.0,*){returnself.searchTextField}else{le

iphone - UISearchBar 文本字段中的自定义清除按钮

我试过:UITextField*searchtextfield=[searchBar.subviewsobjectAtIndex:1];UIButton*cButton=[UIButtonbuttonWithType:UIButtonTypeCustom];cButton.frame=CGRectMake(0,0,20,20);cButton.backgroundColor=[UIColorclearColor];[cButtonsetImage:[UIImageimageNamed:@"x-button"]forState:UIControlStateNormal];//yourbu

iphone - 使 UItextfield 的功能类似于 UISearchBar

我想改变UISearchBar的外观:所以,是否有办法让我的UITextField(在自定义搜索背景中)像UISearchBar一样运行?或者子类化和覆盖-(void)layoutSubviews是唯一的方法?请告诉如何继承它!!! 最佳答案 您可以使用以下代码更改UISearchBar背景..for(UIView*subviewinsearchBar.subviews){if([subviewisKindOfClass:NSClassFromString(@"UISearchBarBackground")]){UIView*bg=

iPhone Objective-C 以编程方式将范围按钮添加到 UISearchBar

我目前的这段代码用于创建UISearchBar(改编自之前的stackoverflow示例):UISearchBar*searchBar=[[UISearchBaralloc]initWithFrame:CGRectZero];[searchBarsizeToFit];//searchBar.delegate=self;searchBar.placeholder=@"Searchmessages,listenersorstations";self.tableView.tableHeaderView=searchBar;UISearchDisplayController*searchDC

ios - 在搜索按钮上隐藏键盘单击代码创建的搜索栏

我使用下面的代码创建了一个搜索栏:UISearchBar*Search=[[UISearchBaralloc]initWithFrame:CGRectMake(150,0,170,50)];[SearchViewaddSubview:Search];但是当我点击搜索按钮时,键盘并没有被隐藏。我使用了很多方法,例如searchBarTextDidEndEditing和searchBarSearchButtonClicked。也许原因是我的搜索栏没有附加。我还在我的.h类和.munload方法中使用了UISearchBarDelegate委托(delegate):Search.delega

ios - 具有 map 应用程序行为的搜索栏(选择时导航栏全宽)

我正在尝试显示一个搜索栏,它的行为与nativemap应用中的搜索栏完全相同。我的意思是:我的导航栏标题View中的搜索栏选中后,搜索栏占据我的导航栏的整个宽度并且我显示SearchDisplayController到目前为止,我设法获得了以下行为:正如您在上面看到的,我无法让搜索栏在选择时占据整个宽度。虽然,全宽+取消按钮似乎是与SearchDisplayControllerHook的搜索栏的默认行为,至少如果搜索栏未添加到导航栏!我是否缺少一种显而易见的方法?还是调用searchBarShouldBeginEditing时需要自己自定义导航栏? 最佳答案

ios - 搜索栏与节标题 View 重叠

我将searchBar放在tableHeaderView中。在iphone6上一切正常,但在iphone5s上我得到了这个奇怪的结果?overridefuncviewDidLoad(){super.viewDidLoad()tableView.delegate=selftableView.dataSource=selftableView.sectionIndexColor=Constants.Colors.ThemeGreentableView.sectionIndexBackgroundColor=UIColor.clearColor()tableView.sectionIndexT

iphone - ios中的过滤器数组检查多个属性

我有一组自定义对象。自定义对象看起来像这样@interfaceUser:NSObject@property(nonatomic,strong)NSString*user_Id;@property(nonatomic,strong)NSString*user_Name;@property(nonatomic,strong)NSString*user_UserName;@end我必须过滤检查2个属性的数组。也就是说,如果我搜索a那么它应该从包含a的数组中过滤用户列表user_Name或user_Id。我怎样才能做到这一点?对于我知道的单个属性[user_Name]NSString*pred