天道酬勤,学无止境

uisearchcontroller

UISearchController with loading indicator

Question 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 Answer1 Updated solution for iOS 13: 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

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

UISearchController misplaces UISearchBar

Question 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

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

UISearchController: searchBar and scopeBar overlap on first touch event

Question I'm trying to implement a simple search bar using Apple's latest UISearchController. However I can't seem to get it to work correctly if I use the search bar's scope bar to get a filter choice. The scope bar always shows which I could live with but on the very first touch event the search bar and scope bar overlap. I used Apple's TableView sample code app but it didn't change anything. - (void)viewDidLoad { [super viewDidLoad]; _resultsTableController = [[APLResultsTableController alloc] init]; _searchController = [[UISearchController alloc] initWithSearchResultsController:self

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

UISearchController searchbar hides the first cell in tableview

Question I have a tableview with a search bar. The search bar is provided by a UISearchController. When I add the search bar to the header view of the table, the first row of the table gets covered by the search bar. How do I prevent the search bar from hiding the first row? I have this snippet in viewDidLoad: self.searchController = UISearchController(searchResultsController: nil) self.searchController.searchResultsUpdater = self self.searchController.searchBar.delegate = self self.tableView.tableHeaderView = self.searchController.searchBar self.searchController

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

Typing in UISearchBar crashes my app

Question UPDATE 2 My app is crashing when presenting it modally after a user taps a button in ViewController1. In my storyboard, I have a standard present modally segue set to pop up the UINavController/UITableViewController containing the UISearchBar. That's failing every time. However, in my AppDelegate, if I set the window's rootViewController to the same UINavController/UITableViewController, everything works as expected. For some reason transitioning via segue and then acting the UISearchBar is causing the crash. UPDATE 1 I'm now receiving the following error when tapping one letter: 2015

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

Strange issue, space of my UISearchController

Question The issue is like this: There has space between searchbar and navbar: And in the Debug in Hierarchy: The table View The wrapper View, we can see the space (20 pix) And in the storyboard, I set the constraint to the tableView, attention: the navigationBar is draged by myself, the native is hide by me. My Code import UIKit import SVProgressHUD class StoreListViewController: UIViewController, UISearchBarDelegate, UITableViewDelegate,UITableViewDataSource, UISearchResultsUpdating { @IBOutlet weak var navbar: UINavigationBar! @IBOutlet weak var tableView: UITableView! var ori_dataSource:

2022-04-28 22:14:08    分类:技术分享    ios   constraints   uisearchcontroller

Tab bar view goes blank when switched back to with search bar active

Question Update 2: Since people are still looking at this question: know that I realized it's impossible to replicate this bug on an actual, isolated iOS device. When you present the search controller, iOS presents a keyboard as well, which covers the tab bar. To switch tabs, you must dismiss the keyboard, which will dismiss the search controller as well. The reason I say "isolated" is because I don't know if you can replicate this with a Bluetooth keyboard and don't have one to try. The iOS keyboard might not be presented with an external keyboard connected Update: I added a viewWillDisappear

2022-04-26 20:12:08    分类:技术分享    ios   swift   uitabbarcontroller   uisearchcontroller

How do I dismiss a UISearchController view?

Question Context: There's a map view with a UISearchController implemented. The search controller displays its results in a different table view controller I found this answer which explains how to dismiss the search controller within the same view. However, my results page is a different view than its origin page. I have let resultsPage = ResultsTableViewController() let searchController = UISearchController(searchResultsController: resultsPage) So now when the search controller gets results, it displays them on the table view controller. When the user selects one of the results, I want to

2022-04-26 18:05:04    分类:技术分享    ios   swift   uisearchcontroller

UISearchController's searchBar doesn't fill full width

Question EDIT: I am using Autolayout. I have a problem filling the full width of my screen with a UISearchController's searchBar. My setup is like so : I have a UIViewController. Inside, I have all my elements separated. There is a UITableView displaying the results. Since I had trouble with the searchBar overlapping the status bar, I created a plain UIView that has constraints so that it lives under the status bar and fills the full width of the UIViewController. This is a method that I have seen numerous time here. Finally, I create the UISearchController and add it as a subview of

2022-04-23 23:10:09    分类:技术分享    ios   iphone   swift   uitableview   uisearchcontroller

Why does the UISearchBar appear to have a strange flash when navigating back?

Question I've got a UISearchBar in my UINavigationItem's titleView associated with a UISearchController. When I navigate back, it appears to flash. Anyone seen this before? vid of flash @interface HNTileSearchViewController () <HNTileSearchResultsProtocol, SWRevealViewControllerDelegate, UISearchBarDelegate, HNSetSearchFiltersProtocol, HNKeywordResultsProtocol> ... @property (nonatomic, strong) UISearchController *searchController; @property (nonatomic, strong) UISearchBar * searchBarTop; ... @end @implementation HNTileSearchViewController ... - (void) customPreSetup {

2022-04-21 11:45:36    分类:技术分享    objective-c   uisearchbar   uisearchcontroller