Tag: uisearchcontroller

search栏点击后消失

我试图使用谷歌地图实现search附近的地方。 下面是我到目前为止所做的代码 override func viewDidLoad() { super.viewDidLoad() //Adding Mapview mapView = GMSMapView(frame: CGRectMake(0, 120, self.view.bounds.width, self.view.bounds.height – 120)) self.view.addSubview(mapView) mapView.mapType = kGMSTypeNormal locationManager.delegate = self locationManager.requestWhenInUseAuthorization() let resultTableView = UITableView(frame: CGRectMake(10, 100, 300, 60)) self.searchResultController = UITableViewController() self.searchResultController?.tableView = resultTableView self.searchResultController?.tableView.dataSource = self self.searchResultController?.tableView.delegate = self self.searchResultController?.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell") self.searchController = UISearchController(searchResultsController: self.searchResultController) self.searchController?.searchResultsUpdater = […]

在UITabBarController中使用UINavigationController时,UISearchBar会被截断

我试图在我的UITabBarController的选项卡之一实现一个search栏,该选项卡是UINavigationController内的UITableViewController …我遵循苹果教程 – 我已经尝试了很多不同的选项,包括这里提到的答案 在UINavigationController中使用带有UITabBarController的UISearchController时,search栏被切断 我已经尝试使用下面的属性设置 self.definesPresentationContext = true 要么 self.tabBarController?.definesPresentationContext = true 这里是我的代码(从UITableViewController包含UISearchBar): /// Search controller to help us with filtering. var searchController: UISearchController! /// Secondary search results table view. var resultsTableController: SearchResultsTableController! override func viewDidLoad() { super.viewDidLoad() resultsTableController = SearchResultsTableController() resultsTableController.tableView.delegate = self searchController = UISearchController(searchResultsController: resultsTableController) searchController.searchResultsUpdater = self searchController.searchBar.sizeToFit() self.tableView.tableHeaderView = […]

UISearchBarController的iOS 11问题 – search栏和范围button重叠

这里和这里提到。 第一个链接没有答案。 在第二个链接,虽然答案不被接受,但链接到苹果开发者论坛给出了错误。 在iOS 11之前: iOS 11: 注意 :相同的设备相同的代码。 另外,这意味着,所有使用此function的应用程序都必须重新发布?

UISearchBar宽度embedded在UINavigationBar内时不会更改

我正在尝试UISearchController引入的新的UISearchController API。虽然API是新的,它使用相同的旧UISearchBar 。 我将它添加到UINavigationController的titleView 。 import UIKit class ViewController: UIViewController, UISearchBarDelegate { override func viewDidLoad() { super.viewDidLoad() let searchController = UISearchController(searchResultsController: nil) searchController.hidesNavigationBarDuringPresentation = false searchController.dimsBackgroundDuringPresentation = false searchController.searchBar.delegate = self navigationItem.titleView = searchController.searchBar } } 我不需要search栏来获取导航栏的整个宽度。 问题是我无法调整它。 首先,我尝试设置search栏的框架。 searchController.searchBar.frame = CGRect(x: 0, y: 0, width: 100, height: 44) 这不起作用,所以我试图设置titleView的框架。 navigationItem.titleView!.frame = CGRect(x: 0, y: […]

你如何引用一个使用故事板的UISearchController

我已经添加了一个search栏和search显示控制器(假设这是我添加的故事板,因为他们没有'SearchController'对象拖出)。 我的问题是我现在如何设置该SearchController属性? self.searchController不起作用,Xcode说,当我将UISearchBar添加到视图时,它会自动添加。 我究竟做错了什么? 我需要访问它的原因是我可以设置结果search表,如下所示: UITableViewController *searchResultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain]; searchResultsController.tableView.dataSource = self; searchResultsController.tableView.delegate = self; self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController]; self.searchController.searchResultsUpdater = self; 我注意到这里的例子: https : //github.com/dempseyatgithub/Sample-UISearchController 其中说它使用故事板,实际上并没有使用故事板添加在UISearchController,但通过分配和初始化和设置框架使用代码。

UISearchController在调用时更改状态栏颜色

我有我的应用程序中的以下代码,特别是在viewDidLoad:设置我的UISearchController 。 self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; self.searchController.searchResultsUpdater = self; self.searchController.hidesNavigationBarDuringPresentation = NO; self.searchController.dimsBackgroundDuringPresentation = NO; self.definesPresentationContext = NO; self.searchController.searchBar.scopeButtonTitles = @[]; self.searchController.searchBar.searchBarStyle = UISearchBarStyleProminent; [_tableView setTableHeaderView:_searchController.searchBar]; 每当调用search栏(添加到tableView ), UIStatusBar颜色将从UIStatusBarStyleLightContent更改为黑色(白色到黑色)。 现在,我想清楚,如果我设置, self.definesPresentationContext = NO; 如下: self.definesPresentationContext = YES; 问题解决了, UIStatusBar颜色被保留了。 然而,另一个问题出现了。 当self.definesPresentationContext被设置为YES ,在调用时,search栏出于某种原因向下移动,恰巧(或正确地)在UIRefreshControl的底部显示在tableView的下方。

iOS 11 Searchcontroller跳转到屏幕顶部

与已发布相同的问题(非答案工作..),我的表是一个固定的宽度,并在iOS 10.x的search栏(这是在tableviewheader),键入时保持相同的大小。 然而,在iOS 11中,它跳转到屏幕的顶部,并在整个宽度上伸展。 所有选项尝试; self.definesPresentationContext = YES; tableHeaderView.clipsToBounds = YES; etc 但似乎没有改变..它仍然跳转到顶部全宽度.. 任何其他选项? Xcode 9通用与iOS 11(Xcode 9通用与iOS 10.x和它一切正常)

UISearchController使控制器变黑

我在iOS 8中使用UISearchController,在tab控制器中embedded视图控制器的viewDidLoad中具有以下intializiton _searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; _searchBar = _searchController.searchBar; [_searchController.searchBar sizeToFit]; _searchController.searchBar.delegate = self; _searchController.searchResultsUpdater = self; _searchController.dimsBackgroundDuringPresentation = NO; _searchController.hidesNavigationBarDuringPresentation = NO; self.definesPresentationContext = NO; _shopsTable.tableHeaderView = _searchController.searchBar; 我已经实施 – (void) updateSearchResultsForSearchController:(UISearchController *)searchController和(void)filterContentForSearchText:(NSString *)searchText 和search工作,tableview得到适当更新,等等。 但! 如果我在search控制器处于活动状态时切换标签页(只是点击search栏或一些文本)到另一个标签页,然后返回到search标签页,那么只有search栏会出现空白屏幕,如下所示 在这种情况下,我search以lar开头的东西,返回结果并正确显示。 但是,如果我切换标签,并返回到search选项卡我得到这样一个空白的屏幕。 控制器返回到原始状态的唯一方法是如果我做_searchController.active = NO 。 但是,如果用户想要保持search活跃,我不能只是停用它。 我相信我失去了一些东西,但由于在UISeachController没有太多的事情,我不知道是什么原因造成的。

UISearchController更改“取消”button标题

我们如何改变search控制器中取消button的标题?

UISearchController:searchBar和scopeBar在第一个触摸事件上重叠

我正在尝试使用Apple最新的UISearchController实现一个简单的search栏。 但是,我似乎无法让它正常工作,如果我使用search栏的范围栏来获得筛选器的select。 范围栏总是显示我可以住在哪里 但在第一次触摸事件时,search栏和范围栏会重叠。 我使用Apple的TableView示例代码应用程序,但它没有改变任何东西。 – (void)viewDidLoad { [super viewDidLoad]; _resultsTableController = [[APLResultsTableController alloc] init]; _searchController = [[UISearchController alloc] initWithSearchResultsController:self.resultsTableController]; self.searchController.searchResultsUpdater = self; [self.searchController.searchBar sizeToFit]; self.searchController.searchBar.showsScopeBar = YES; [self.searchController.searchBar setScopeButtonTitles:@[@"First",@"Second"]]; self.tableView.tableHeaderView = self.searchController.searchBar; // we want to be the delegate for our filtered table so didSelectRowAtIndexPath is called for both tables self.resultsTableController.tableView.delegate = self; self.searchController.delegate […]