草庐IT

UIsearchBar

全部标签

ios - 在搜索结果 TableView 中选择行后 UISearchBar 消失

有谁知道为什么我的UISearchbar在用户点击搜索结果表中的单元格后消失了?发生的事情是用户在搜索某些内容后点击一个单元格,然后打开一个新View。但是,当您返回到原始搜索ViewController时,搜索栏消失了,顶部单元格位于顶部栏下方。 最佳答案 为了解决这个问题,我不得不在按下一个单元格后关闭搜索结果表格View。因此,当用户返回到之前的View时,搜索结果被取消,原来的tableview再次出现。 关于ios-在搜索结果TableView中选择行后UISearchBar消

ios - scopeBar 第一次激活时不显示在 UISearchBar 下

我以编程方式创建了一个UISearchController,并在viewDidLoad中设置范围按钮标题UITableViewController*searchResultsController=[[UITableViewControlleralloc]initWithStyle:UITableViewStylePlain];searchResultsController.tableView.dataSource=self;searchResultsController.tableView.delegate=self;[searchResultsController.tableView

ios - 将搜索栏添加到 UICollectionView

我创建了一个CollectionView(作为IB中的CollectionViewController),我突然想到我应该有一个搜索功能。我想在Storyboard中的CollectionView上方添加一个SearchBar,但实际上它不允许我一直在下方滑动,这显然是行不通的。有没有办法解决这个问题,或者我是否需要从头开始重建我的CollectionViewController并在顶部设置SearchBar?我能否以编程方式将SearchBar添加到现有的CollectionViewController中?引用图片: 最佳答案 我

ios - 如何以编程方式关闭 UISearchBar?

我正在使用UISearchController和UITableView。WhenacellintheUITableViewisselected,I'maddingablackUIViewabovethewholescreenwithsomesubviewsonit.当UISearchController处于非事件状态时,它工作得很好。但是当它处于事件状态时,UISearchBar会显示在我的黑色View上方。self.searchController=[[UISearchControlleralloc]initWithSearchResultsController:nil];self.

objective-c - 没有 UITableView 的 UISearchDisplayController

是否可以在没有UITableView的情况下实现UISearchDisplayController?或者至少隐藏TableView? 最佳答案 只需在您的View中创建一个UISearchBar实例并实现UISearchBarDelegate协议(protocol)。确保您的View也设置为搜索栏的委托(delegate)。当用户单击完成按钮时,它将向委托(delegate)方法searchBarSearchButtonClicked发送一条消息:-(void)viewDidLoad{[superviewDidLoad];self.

ios - UISearchDisplayController CGContext 错误 iOS 7

我在我的应用程序中使用UISearchDisplayController。自iOS7以来,出现了一个奇怪的错误,当点击搜索栏并显示键盘时,如果用户决定再次点击搜索栏,而“searchField”为空,应用程序会给出几个错误。这个问题在这个线程中讨论:UISearchBarCGContextERROR现在我有两个问题:有什么办法可以解决这个问题吗?如果没有,您可以将系统中存在此错误的应用程序上传到AppStore吗?问候我的代码:-(void)viewDidLoad{[superviewDidLoad];if([selfsystemVersionGreaterThanOrEqualTo:

iOS 11 UISearchBar : left + rightbarbuttonitem vertical center issue

在IOS11中,我在UISearchController中遇到了另一个问题。由于默认高度值变为56,rightBarButtonItem和leftBarButtonItem保留在原来的位置,无论是文本还是图像。我需要像在IOS10中一样将项目置于搜索栏的中心。refreshbuttonsarenotcentered如您所见,项目按钮略高于搜索栏的中心。我尝试这样做:[self.searchController.searchBar.heightAnchorconstraintLessThanOrEqualToConstant:44].active=YES;但是我有搜索栏重叠按钮:sear

导航栏中不出现小延迟后添加的 iOS 搜索栏

如果我在延迟0.1秒后添加搜索栏,则它不会出现在导航栏中。如果我将延迟更改为0.5秒,它就会出现。这是因为当延迟很短时它会在推送动画期间运行吗?如何让它在0.1秒延迟后显示?-(void)viewDidLoad{[superviewDidLoad];doubledelayInSeconds=.1;dispatch_time_tpopTime=dispatch_time(DISPATCH_TIME_NOW,(int64_t)(delayInSeconds*NSEC_PER_SEC));dispatch_after(popTime,dispatch_get_main_queue(),^{s

objective-c - 如何设置UISearchBar的颜色

谁能告诉我如何设置UISearchbar的颜色,使其遵循地址簿中使用的搜索栏的颜色?它的颜色是浅灰色,取消按钮是深色调。我试过代码://SercolorofUISearchbarsBar.tintColor=[UIColorlightGrayColor];但无法复制(按钮颜色的)颜色和效果。 最佳答案 您需要设置搜索栏的色调属性。例如historySearchBar.tintColor=[UIColorcolorWithRed:129.0/255.0fgreen:129.0/255.0fblue:130.0/255.0falpha:

ios - 将 UISearchBar 取消按钮更改为图标

我想将UISearchBar的Cancel按钮更改为只有图像而没有文本的按钮。这是我与原始行为相去甚远的地方对此朝着正确的方向迈出了一步,但问题是按钮太宽了。当我调试View时,我可以看到它在左右两侧有11个点的按钮标签插入。有人知道如何使按钮适合内容大小吗?图像是方形的。这是我自定义按钮的代码:UIBarButtonItem*barButtonAppearanceInSearchBar;if(IOS9){barButtonAppearanceInSearchBar=[UIBarButtonItemappearanceWhenContainedInInstancesOfClasses: