草庐IT

Searchbar

全部标签

ios - 导航 Controller swift 中的中心搜索栏

我需要将导航Controller中搜索栏的方向更改为中心。我使用以下代码以编程方式创建了搜索栏:lazyvarsearchBar:UISearchBar=UISearchBar(frame:CGRectMake(100,40,440,40))并在viewDidLoad中:searchBar.placeholder="SearchforPlaces"varleftNavBarButton=UIBarButtonItem(customView:searchBar)self.navigationItem.leftBarButtonItem=leftNavBarButton但是我在左边也有一个

ios - 如何更改 SearchBar 边框颜色

我想将我的搜索栏中的灰色边框颜色更改为白色。现在看起来像这样:我用这行代码实现了这个效果,但是“insideborder”还是灰色的:varsearchBar:UISearchController!self.searchBar.searchBar.backgroundColor=UIColor.whiteColor()self.searchBar.searchBar.layer.borderWidth=3self.searchBar.searchBar.layer.borderColor=UIColor.whiteColor().CGColorself.searchBar.search

swift - 为 UISearchBar 设置的谓词更新 fetchedResultsController

重构为VanillaUIViewController而不是拥有UITableView在事件和非事件之间切换UISearchController,我重构为VanillaUIViewController用UISearchBar在顶部和一个UITableView就在它的正下方。我想做的是切换fetchedResultsController在具有由searchBar中的文本设置的谓词和抓取所有内容的谓词之间。我找到了这个答案,它描述了Objective-C中类似问题的解决方案,并作为我重构Swift项目的基础:如何使用UISearchDisplayController/UISearchBar过

ios - Swift ios11 NavigationItem SearchBar 不会完全隐藏

在iOS11/Swift4中将搜索Controller添加到navigationItem时出现问题。基本上一切都按预期工作,下拉将显示搜索栏,搜索工作正常。然而,当试图通过向上滚动来隐藏搜索栏时...搜索栏不会完全隐藏,而是保持为一条细条(见下文)。我已经声明我的搜索Controller如下:letsearchController=UISearchController(searchResultsController:nil)searchController.searchResultsUpdater=selfsearchController.dimsBackgroundDuringPre

ios - 如何在 navigationBar (UITableView) swift 下添加 SearchController.searchBar

我尝试在导航栏下添加SearchController.searchBar。overridefuncviewDidLoad(){super.viewDidLoad()searchController=UISearchController(searchResultsController:nil)searchController.searchResultsUpdater=selfsearchController.searchBar.sizeToFit()searchController.hidesNavigationBarDuringPresentation=falsesearchContr

ios - 为什么我的 UISearchBar 不遵守约束?

在我的iOS应用程序中,我有一个由UISearchBar和UIStackView中的UIButton组成的导航栏。由于我无法对UISearchController进行Storyboard,因此我在堆栈View中有一个空白的UIView并且我将UISearchBar添加为subview。这是我的Storyboard的样子:这是我添加搜索栏的代码overridefuncviewDidLoad(){super.viewDidLoad()configureSearchController()print(wrapperView.bounds)print(searchController.sear

ios - 用户取消搜索时约束不变

所以我有一个搜索图标作为我的右栏按钮项。当用户点击该图标时,它允许用户搜索并仅在表格View中显示某些值。它还隐藏了顶部的导航栏按钮和导航Controller正下方的filterBarfuncsetupNavBarButtons(){letsearchImage=UIImage(named:"search_icon")?.withRenderingMode(.alwaysOriginal)letsearchBarButtonItem=UIBarButtonItem(image:searchImage,style:.plain,target:self,action:#selector(h

ios - 如何在 swift 3 中通过 SearchBar 按电子邮件地址搜索联系人?

我正在通过以下代码从swift3的联系人框架中获取联系人funcgetContctFromContactBook(_completion:@escapingContactsHandler){ifcontactsStore==nil{//ContactStoreiscontrolforaccessingtheContactscontactsStore=CNContactStore()}switchCNContactStore.authorizationStatus(for:CNEntityType.contacts){caseCNAuthorizationStatus.denied,CN

arrays - UITableView SearchBar过滤查询

我有一个很长的tableView,可以搜索和过滤结果。但是,如果我输入字母“i”作为输入,所有带有字母“i”的单词都会出现。是否可以通过某种方式进行过滤,使我键入的字母对应于我要过滤的单词的第一个字母。例如我的数组["shouldnotuse","Tristan","biscuit","is","shouldnotuse"]如果我搜索单词"is",那个词能自动出现在“biscuit”这个词之前吗?ExpectedResult:["is","biscuit","Tristan"] 最佳答案 您可以使用filter和sorted函数来获

ios - 以编程方式 UISearchBar 未显示

我以编程方式创建了一个UISearchBar(不是UISearchController)并将其设置为tableviewheader。但是,它没有出现。任何人都可能知道这是为什么?课外:varsearchBar=UISearchBar()在viewDidLoad方法中。searchBar.barTintColor=UIColor(red:0.54,green:0.77,blue:0.80,alpha:1.0)searchBar.placeholder="Cautacheltuieli"searchBar.backgroundImage=#imageLiteral(resourceName