天道酬勤,学无止境

uisearchcontroller

UISearchController with loading indicator

问题 回答1 extension UISearchBar { var textField: UITextField? { if #available(iOS 13.0, *) { return searchTextField } else { if let textField = value(forKey: "searchField") as? UITextField { return textField } return nil } } private var activityIndicator: UIActivityIndicatorView? { return textField?.leftView?.subviews.compactMap{ $0 as? UIActivityIndicatorView }.first } var isLoading: Bool { get { return activityIndicator != nil } set { if newValue { if activityIndicator == nil { let newActivityIndicator = UIActivityIndicatorView(style: .gray) newActivityIndicator.startAnimating() if #available

2022-05-14 09:34:04    分类:技术分享    ios   objective-c   loading   uisearchcontroller

UISearchController misplaces UISearchBar

问题 我在模式页面上使用 UISearchController 来允许用户搜索一些数据。 该页面使用表格视图控制器设计,并且 searchBar 位于 tableViewCell 中。 当用户点击 searchBar 时,UISearchController 会为布局设置动画以将表格标题滑动到页面顶部并移动搜索栏。 但是,它最终不会出现在正确的位置。 它没有充分向上移动。 有人对如何帮助 UISearchController 正确定位 searchBar 有任何建议吗? 在点击搜索栏之前(看起来不错) 点击搜索栏后(搜索栏在错误的位置)

2022-05-11 14:18:44    分类:技术分享    ios   uisearchbar   uisearchcontroller

UISearchController: searchBar and scopeBar overlap on first touch event

问题 我正在尝试使用 Apple 最新的 UISearchController 实现一个简单的搜索栏。 但是,如果我使用搜索栏的范围栏来获得过滤器选择,我似乎无法让它正常工作。 范围栏总是显示我可以接受的 但在第一次触摸事件中,搜索栏和范围栏重叠。 我使用了 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:@[@

2022-05-11 12:49:12    分类:技术分享    ios   cocoa-touch   uikit   uisearchbar   uisearchcontroller

UISearchController searchbar hides the first cell in tableview

问题 我有一个带有搜索栏的表格视图。 搜索栏由 UISearchController 提供。 当我将搜索栏添加到表格的标题视图时,表格的第一行被搜索栏覆盖。 如何防止搜索栏隐藏第一行? 我在 viewDidLoad 中有这个片段: self.searchController = UISearchController(searchResultsController: nil) self.searchController.searchResultsUpdater = self self.searchController.searchBar.delegate = self self.tableView.tableHeaderView = self.searchController.searchBar self.searchController.dimsBackgroundDuringPresentation = false self.searchController.searchBar.sizeToFit() 回答1 self.searchController.searchBar.scopeButtonTitles = [NSArray array]; 回答2

2022-05-11 06:57:04    分类:技术分享    uitableview   uisearchcontroller

Typing in UISearchBar crashes my app

问题 更新 2 在用户点击 ViewController1 中的按钮后,我的应用程序在模态显示时崩溃。 在我的故事板中,我设置了一个标准的present modally segue 以弹出包含UISearchBar的 UINavController/UITableViewController 。 每次都这样失败。 但是,在我的AppDelegate中,如果我将窗口的rootViewController设置为相同的 UINavController/UITableViewController,一切都会按预期工作。 出于某种原因,通过 segue 转换然后执行 UISearchBar 会导致崩溃。 更新 1 点击一个字母时,我现在收到以下错误: 2015-02-03 12:23:35.262 Afar D[28348:2740681] -[NSNull length]: unrecognized selector sent to instance 0x10e352ce0 2015-02-03 12:23:40.313 Afar D[28348:2740681] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized

2022-05-10 05:32:08    分类:技术分享    objective-c   uitableview   ios8   uisearchbar   uisearchcontroller

UISearchBar in UITableView header layout issue in iOS 14

I am using the new UISearchController with searchbar inside tableview header.Everything works fine in portrait orientation but when I rotate to landscape and uisearchbar start editing its frame is out of screen,clipping the cancel button. my code for creating searchcontroller tableView.tableHeaderView = searchController.searchBar Here is my sample code UISearchController sample Rotation has no frame issue in landscape but only when uisearchbar starts editing [ When rotate back to portrait layout of uisearchbar is still incorrect There is no issue if I use UITableviewController but I have to

2022-05-03 07:11:44    分类:问答    ios   swift   autolayout   uisearchbar   uisearchcontroller

how to filter section wise row in tableview?

I'm new in iOS and creating a demo app on basis of JSON response. my query is I don't know how to write and filter row data section wise to show on tableview. category.json [file] { "category": [ { "vName": "Section 0", "skill": [ { "vName": "Section 0 Row 1", }, { "vName": "Section 0 Row 2", } ] }, { "vName": "Section 1", "skill": [ { "vName": "Section 1 Row 1", }, { "vName": "Section 1 Row 2", } ] }, { "vName": "Section 2", "skill": [ { "vName": "Section 2 Row 1", }, { "vName": "Section 2 Row 2", } ] }, { "vName": "Section 3", "skill": [ { "vName": "Section 3 Row 1", }, { "vName": "Section 3

2022-04-30 09:19:01    分类:问答    ios   swift   uitableview   uisearchcontroller

The searchController doesn't appear in the navigationItem after reloading the ViewController (Swift 5)

In my application, I'm using the searchController that I placed in the navigationItem. I create a searchController like this: class FirstVC: UIViewController, UITableViewDelegate, UITableViewDataSource { private var searchController = UISearchController() var creator: FirstVC? @IBOutlet var navigationBarItem: UINavigationItem! override func viewDidLoad() { super.viewDidLoad() searchController = setupSearchController() navigationBarItem = searchController } private func setupSearchController() -> UISearchController { let controller = UISearchController(searchResultsController: nil) ... return

2022-04-30 05:38:34    分类:问答    ios   swift   uinavigationbar   uisearchbar   uisearchcontroller

UISearchController misplaces UISearchBar

I am using the UISearchController on a modal page to allow a user to search some data. The page uses a table view controller design and the searchBar is in a tableViewCell. When the user taps on the searchBar, the UISearchController animates the layout to slide the table header to the top of the page and moves the searchbar. However it does not end up in the right place. It does not move sufficiently up. Anyone have a suggestion on how to help the UISearchController to position the searchBar correctly? Before tapping the search bar (looks ok) After tapping the search bar (search bar in wrong

2022-04-29 09:29:28    分类:问答    ios   uisearchbar   uisearchcontroller

UISearchController with loading indicator

I implemented UISearchController and I'm getting the data from a js callback but when I tape in the searchbar it takes some time to put the data so I wanted to know how to implement a loading indicator into the table view result of UISearchController

2022-04-29 06:00:00    分类:问答    ios   objective-c   loading   uisearchcontroller