Tag: uisearchcontroller

Swift – 自定义SearchController和SearchBar

我试图重新创build在雅虎财经应用程序中看到的search字段。 我跟着一个在线教程来定制UISearchBar和UISearchController,但是我仍然有一些问题。 如果你们中的任何一个人能够打开我的项目,看看哪里出了问题,哪里需要添加这些线路,哪怕这些线路真的很棒。 我的尝试解决scheme项目可以在这里find: https : //github.com/jordanw421/yahoofinance 1)如何让查询出现的时候,search栏处于激活状态(文本向左​​,input指示灯闪烁)? 在下面的链接中,您可以看到我在说什么,当button被按下时,search视图被加载,search栏立即被激活。 我试过使用: customSearchController.definesPresentationContext = true customSearchController.isActive = true customSearchController.searchBar.becomeFirstResponder() 但是这并没有奏效。 我应该在prepareForSegue的初始视图控制器中设置这些吗? 2)如何设置键盘外观(黑暗),并添加一个button的键盘工具栏? 我能够得到这个工作非自定义search栏,但出于某种原因,这些现在不工作: customSearchController.searchBar.keyboardAppearance = .dark 和 func addKeyboardButton() { let keyboardToolbar = UIToolbar() keyboardToolbar.sizeToFit() keyboardToolbar.isTranslucent = false keyboardToolbar.barTintColor = UIColor.blue let addButton = UIButton(type: .custom) addButton.frame = CGRect(x: keyboardToolbar.frame.size.width / 2, y: keyboardToolbar.frame.size.height / 2, width: […]

search栏在input时从视图中消失

我在ViewDidLoad()添加了SearchBar到我的TableView中: self.searchBar = UISearchController(searchResultsController: nil) self.searchBar.searchResultsUpdater = self self.searchBar.dimsBackgroundDuringPresentation = false self.searchBar.searchBar.sizeToFit() self.tableView.tableHeaderView = self.searchBar.searchBar self.tableView.reloadData() 一切工作正常,但是当我点击这个SearchBar它消失。 这意味着,我仍然可以打字,我可以看到结果,但是,没有看到SearchBar 。 我实现了UISearchBarDelegate ,我一直在试图添加 func searchBarTextDidBeginEditing(searchBar: UISearchBar) { self.navigationController?.navigationBarHidden = false } func searchBarTextDidEndEditing(searchBar: UISearchBar) { self.navigationController?.navigationBarHidden = true } 但它仍然不起作用。 你有什么想法,为什么这个Search Bar消失? 这个问题的解决方法是(像@sandy悲伤)在viewDidLoad()写这行代码 self.aNavigationController?.extendedLayoutIncludesOpaqueBars = true 但现在我有一个新的问题,这是什么意思当我在TableViewselect行并显示新的VievController , SearchBar不会消失,我在新的视图中看到它。 为什么?

search栏越来越消失在ios UIsearchcontroller

我正在使用UISearchController ,当我点击search栏,我得到的animation,就好像search栏是去呈现searchcontroller的导航栏与衰落的animation,但它消失,键盘介绍呆在那里。 在viewcontroller.m中,viewdidload方法,相关部分: UIView *searchView = [[UIView alloc]initWithFrame:CGRectZero]; searchResultsViewController =[[SearchResultsViewController alloc]initWithNibName:@"SearchResultsViewController" bundle:nil]; self.searchController =[[UISearchController alloc]initWithSearchResultsController:nil]; self.searchController.searchResultsUpdater=self; self.searchController.dimsBackgroundDuringPresentation = NO; searchView = self.searchController.searchBar; self.definesPresentationContext = YES; self.searchController.searchBar.delegate=self; searchView.frame =CGRectMake(0, 50, [[UIScreen mainScreen]bounds].size.width, 40); [self.view addSubview:searchView]; SearchResultsViewController是一个具有过滤数组的UIViewController ,它从ViewController中的-(void)updateSearchResultsForSearchController:(UISearchController *)searchController方法获取其值 随着search栏消失,我试图把search栏作为ViewController中的TableView的标题,它正常工作。 但是当我把search栏视图作为自定义的创build视图,而不是表头,它正在消失。 任何有识之士将不胜感激。 谢谢

如何创buildUISearchController,因为UISearchDisplayController在iOS 8中已被弃用?

IB中没有UISearchController,只有UISearchDisplayController; 我在哪里可以find关于创build它的文档?

xcode将文本string加载到UISearchController中

我正在使用这个例子通过UICollectionView进行search: https : //github.com/ihomam/CollectionViewWithSearchBar/blob/master/collevtionViewWithSearchBar/CollectionViewController.m – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; // Configure the cell if (self.searchBarActive) { cell.laName.text = self.dataSourceForSearchResult[indexPath.row]; } else { cell.laName.text = self.dataSource[indexPath.row]; } return cell; } …只有我的应用程序设置有点不同: – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { PlaceCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; Place *p = [_entries […]

UISearchController错位UISearchBar

我在模态页上使用UISearchController来允许用户search一些数据。 该页面使用表格视图控制器devise,并且searchBar位于tableViewCell中。 当用户点击searchBar时,UISearchControlleranimation布局将表格标题滑动到页面顶部并移动search栏。 然而,它并没有在正确的地方结束。 它没有足够的移动。 任何人有关于如何帮助UISearchController正确定位searchBar的build议? 在点击search栏之前(看起来确定) 点击search栏(search栏位置不正确)

UISearchController – 键盘不显示

我正在使用UISearchController和searchfunction,除了两件事。 也许他们是相关的:a)键盘不显示。 所以我不能按“search”buttonb)在我的主TableView我访问样式单元格的样式“副标题”。 当进行search时,显示的单元格是“基本”样式。 在这两种情况下(TableViewController和SearchViewController)我使用相同的单元格标识符。 有任何想法吗? 这里的一些代码: class OverviewTableViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() let resultsController = SearchResultsController() resultsController.birds = birds searchController = UISearchController(searchResultsController: resultsController) //searchController.dimsBackgroundDuringPresentation = true let searchBar = searchController.searchBar searchBar.scopeButtonTitles = ["One", "Two"] searchBar.placeholder = "Search" searchBar.sizeToFit() tableView.tableHeaderView = searchBar searchController.searchResultsUpdater = resultsController 和第二类: class SearchResultsController: UITableViewController, UISearchResultsUpdating { var […]

UISearchController保留问题

我正在尝试使用UISearchController,但是我遇到了我无法解决的保留问题。 MainTableview有两个部分。 第一节 基于一些正则expression式的过滤数据 第二节 所有数据 我添加了UISearchController到我的tableview,并把ResultsTableController作为resultsTableController。 它工作时,用户search的东西,ResultsTableController前进,因为我设置tableview委托自我,从ResultsTableController中select项目调用didToolViewController中的didSelectRowAtIndexPath。 不过,如果用户从resultsTableController中select一些东西,我有分配问题。 以下情况发生在不同的场景 用户不search任何东西,只要从MainTableview中select一个项目,我看到deinit消息 用户search的东西,取消search,从MainTableviewselect项目,我看到deinit消息 用户search的东西,并从ResultsTableController中select一个项目,我不看我的viewcontrollers MainTableViewController.swift var searchController: UISearchController! // Secondary search results table view. var resultsTableController: ResultsTableController! var allCompanies = ["Data1","Data2","Data3"] override func viewDidLoad() { super.viewDidLoad() resultsTableController = ResultsTableController() // We want to be the delegate for our filtered table so didSelectRowAtIndexPath(_:) is called for both […]

UISearchController searchBar在第一次点击时消失

我已经在TableView中实现了一个UISearchController,由导航控制器推送。 首先我的问题是,每当我点击SearchBar时,它就会消失。 当我input一些文字时,它会起作用,但它保持完全空白。 然后我设法使用这个代码半解决问题: – (void)searchForText:(NSString*)searchText { [self.view addSubview:villeSearchController.searchBar]; } 因为现在是半工作的,当我点击search栏时,它会空白,但是如果我input一个字符,就会再次出现,然后它就停留在那里,不pipe怎样。 直到我取消search,然后再次点击它,在这种情况下,它空白。 我做了一些testing,并且这个方法(searchForText)在第一次点击时被调用,所以这不是原因。 有谁知道我可以如何解决这个问题,并使第一次点击search栏出现? 编辑: 这是我如何初始化SearchController: villeSearchController = [[UISearchController alloc] initWithSearchResultsController:nil]; villeSearchController.searchResultsUpdater = self; villeSearchController.dimsBackgroundDuringPresentation = NO; villeSearchController.searchBar.delegate = self; villeTableView.tableHeaderView = villeSearchController.searchBar; villeSearchController.searchBar.scopeButtonTitles = @[]; self.definesPresentationContext = YES; [villeSearchController.searchBar sizeToFit];

与Segue的UISearchbar(UISearchResultsUpdating)不排除

我有一个UISearchBar的问题。 当我search一些与UITableView相结合的文本,并单击一个结果单元格时, UISearchBar在下一个UIViewController仍然可见。 UISearchbar仍然存在(与关键字) 所以,当你点击一个结果,生病(在下一个视图控制器),但search栏和键盘仍然显示。 我如何解雇目前的UISearchController ,使search栏和键盘不显示在下一个UIViewController ? 我努力了: definesPresentationContext = true 我试图解雇presentingViewController 。 我在做准备for segue所有这一切。 我的想法是,我必须解雇UISearchController …但我怎么能在UISearchController访问它(在searchResultsViewControllers – 这是一个tableViewController是用来呈现searchResults )