Tag: uisearchcontroller

为什么在searchBar和tableview之间添加空格?

我有一个tableview控制器。 我添加了searchBar。 但是,当我点击search条,我有一个空格之间的searchBar和TableView? 为什么? 它是如何修复的? 在向下我添加屏幕截图和代码tableViewController列表。 感谢帮助。 !!!!!! – 列表TableViewController – !!!!!! class AlfavitController: UITableViewController, UISearchResultsUpdating { var searchController : UISearchController! var resultController = UITableViewController() override func viewDidLoad() { super.viewDidLoad() self.downloadData(param: Manager.id) tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") self.searchController = UISearchController(searchResultsController: self.resultController) self.tableView.tableHeaderView = self.searchController.searchBar self.searchController.searchResultsUpdater = self self.resultController.tableView.dataSource = self self.resultController.tableView.delegate = self definesPresentationContext = true } […]

UISearchController searchBar在按下viewcontroller时不会消失

我使用UISearchController里面包含一个UITableView UIViewcontroller ,我这样做viewDidLoad : self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; self.searchController.delegate = self; self.searchController.searchResultsUpdater = self; self.searchController.searchBar.delegate = self; self.searchController.dimsBackgroundDuringPresentation = NO; self.searchController.hidesNavigationBarDuringPresentation = NO; self.definesPresentationContext = NO; 当我在导航栏中按下button时,我这样做: self.tableView.contentOffset = CGPointMake(0, 0 – self.tableView.contentInset.top); self.tableView.tableHeaderView = self.searchController.searchBar; [self.searchController.searchBar becomeFirstResponder]; 所有工作正常,但是当我从UITableView结果行中推UIViewController的UISearchBar呆在那里,也显示在另一个视图的内容,我怎么可以解雇,当我推视图,当我回去看到UITableView结果? 谢谢 编辑: 这是方法didSelectRowAtIndexPath的代码: – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; DetailListController *detailList = […]

如何使用UISplitView自适应用户界面呈现UISearchController?

使用具有自适应UISplitViewController用户界面的通用故事板。 我想使用下面的代码(来自主视图控制器)在主(主)侧显示search控制器: static NSString * const kCGISearchViewControllerID = @"SearchViewControllerID"; – (IBAction)searchButtonClicked:(UIBarButtonItem *)__unused sender { SearchViewController *searchResultsController = [self.storyboard instantiateViewControllerWithIdentifier:kCGISearchViewControllerID]; self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController]; self.searchController.searchResultsUpdater = searchResultsController; self.searchController.hidesNavigationBarDuringPresentation = NO; [self presentViewController:self.searchController animated:YES completion:nil]; } 它最初似乎工作正常(不pipe起始方向): 自动旋转后出现问题(键盘仍然可见,底层内容仍然变暗,但search栏消失): 在旋转回风景时,search栏会重新出现,但其宽度现在是错误的: (我也尝试将search控制器的searchBar放置在searchBar中,而searchBar正确调整时,search结果控制器仍然看起来不正确。) 我错过了一个呈现的UISearchController ,当UI适应不断变化的大小类时正确地animation本身? 更新: 添加self.definesPresentationContext = YES; 获取search栏/结果出现在主视图中,但search栏在该导航栏下animation,并且不可见。 另一个问题是,从纵向(有状态栏)旋转回到横向时,search栏高度不会缩小。

UISearchController不会消除search栏和iOS 8 Swift的重叠

我遇到了UISearchController的问题,如果我在search栏中有文本,并closures它的VC,searchBar将不会消失,只是在屏幕上重叠其他VC中的所有内容。 然后,如果你点击取消button,它会崩溃。 已经尝试了几个解决scheme,但都没有工作。 :/ self.resultSearchController = ({ let controller = UISearchController(searchResultsController: nil) controller.searchResultsUpdater = self controller.dimsBackgroundDuringPresentation = false controller.hidesNavigationBarDuringPresentation = false controller.searchBar.sizeToFit() controller.searchBar.searchBarStyle = UISearchBarStyle.Minimal controller.searchBar.barTintColor = UIColor(red: 243/255, green: 243/255, blue: 243/255, alpha: 1) controller.searchBar.tintColor = UIColor.blackColor() controller.definesPresentationContext = true controller.edgesForExtendedLayout = UIRectEdge.None self.tableView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0) self.tableView.tableHeaderView = controller.searchBar return controller […]

如何将UISearchController的searchBar设置为不是tableHeaderView或navigationItem.titleview的视图?

我试图保持search栏在视图中滚动。 目前,我把它作为桌面视图中的标题,它的工作原理应该是这样,但当然,search栏会在屏幕下滚动屏幕。 我以为我可以做这个简单的修改这个代码示例: 我如何使用UISearchController在UISearchBar在我的导航栏,并具有范围button的iOS 8? searchController = UISearchController(searchResultsController: nil) searchController.searchResultsUpdater = self searchController.delegate = self searchController.searchBar.delegate = self searchController.dimsBackgroundDuringPresentation = false searchController.hidesNavigationBarDuringPresentation = false tableview.tableHeaderView = searchContoller.searchBar // How to put it elsewhere? //Alternative that also works navigationItem.titleView = searchController.searchBar 这个想法是采取一些其他的观点和做法 otherview = searchController.searchBar 例如一个UISearchBar的出口,或者一个空白的UIView,或类似的东西。 但是,如果我这样做,它不显示searchBar。 它似乎只能作为一个表的标题视图或作为navigationItem.titleView。 我错过了什么吗?

使用UISearchController时,UITableView单元上的Peek和Pop失败

Peek和Pop正在使用UISearchController 。 但是,一旦开始使用updateSearchResultssearch表,Peek和Pop将停止工作。 我已经使用UISearchController演示扩展了Apple的Table Search以支持Peek和Pop作为示例: 问题是当我开始search表时,Peek和Pop不再工作。 它只是select突出显示它: 我做的更新是MainTableViewController是: class MainTableViewController: BaseTableViewController, UISearchBarDelegate, UISearchControllerDelegate, UISearchResultsUpdating { override func viewDidLoad() { super.viewDidLoad() … if traitCollection.forceTouchCapability == .available { registerForPreviewing(with: self, sourceView: tableView) } } } extension MainTableViewController: UIViewControllerPreviewingDelegate { func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { guard let indexPath = tableView?.indexPathForRow(at: location), let cell […]

带有加载指示器的UISearchController

我实现了UISearchController ,我从jscallback中获取数据,但是当我在searchsearchbar放入数据时,需要一些时间来放置数据,所以我想知道如何在UISearchController的表视图结果中实现一个加载indicator

奇怪的问题,我的UISearchController的空间

问题是这样的: searchnavbar和navbar之间有空格: 在“ Debug in Hierarchy中的Debug in Hierarchy : 表视图 包装视图,我们可以看到空间(20 pix) 在storyboard ,我将约束条件设置为tableView ,注意: navigationBar是由我自己绘制的,本地人是由我隐藏的。 我的代码 import UIKit import SVProgressHUD class StoreListViewController: UIViewController, UISearchBarDelegate, UITableViewDelegate,UITableViewDataSource, UISearchResultsUpdating { @IBOutlet weak var navbar: UINavigationBar! @IBOutlet weak var tableView: UITableView! var ori_dataSource: [StoreListModel] = [StoreListModel]() var dataSource = [String]() var filterdDataSource = [String]() var resultSearchController = UISearchController() […]

search后访问索引path行

我用数据填充表格,并按照预期工作 – 包括将每行的细节延续到另一个场景。 我在那里抛出一个search栏(以编程方式 – 使用新的searchController),它成功地重新加载了原来的表与任何发现的结果。 但是,在search之后触摸选定的行时,传递的是与原来的表格行相同的原始表格行,它现在与现在触摸的表格的位置相同! (即如果我selectsearch的当前第二行,则下一个场景会延续原始表的第二行的细节!) 那么如何在search后提供prepareForSegue函数我的正确的行? 这是细胞的创造: override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell if (self.resultSearchController.active) { cell.textLabel?.text = filteredTableData[indexPath.row] return cell } else { cell.textLabel?.text = TableTitle[indexPath.row] return cell } } 这是searchfunction: func updateSearchResultsForSearchController(searchController: UISearchController) { filteredTableData.removeAll(keepCapacity: false) let searchPredicate […]

如果使用UISearchController重新加载数据,导航栏将消失

我的应用程序工作,以便我在UI​​CollectionViewController内的可重用视图中有一个UISearchController。 当点击search栏时,我点击任何结果,并触发一个通知重新加载collectionView,以反映更改。 lazy var searchController: UISearchController = { let tableViewController = UITableViewController(style: .Plain) tableViewController.tableView.dataSource = self tableViewController.tableView.delegate = self tableViewController.tableView.registerClass(StoreListCell.self, forCellReuseIdentifier: "MiniStoreCell") let searchController = UISearchController(searchResultsController: tableViewController) searchController.searchResultsUpdater = self searchController.searchBar.frame = CGRect(x: 0, y: 0, width: CGRectGetWidth(self.collectionView.frame), height: 44) return searchController }() override func viewDidLoad() { super.viewDidLoad() definesPresentationContext = true collectionView.registerClass(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: […]