uisearchcontroller

UISearchController: show results even when search bar is empty

孤人 提交于 2019-11-29 22:57:18
As I understand, the default behaviour of UISearchController is: On tapping search bar, background is dimmed and 'cancel' button is shown. SearchResultsController is not shown till this point. SearchResultsController is displayed only if search bar is not empty. I want to display SearchResultsController even when search bar is empty but selected (i.e is case 1 above). Simply put, instead of background dimming, I would like to show Search results. Is there a way for doing this? More Clarification: I am not using UISearchController to filter results shown on the view on which it is shown, but

Change UISearchBar cancel button text in iOS 8

▼魔方 西西 提交于 2019-11-29 21:20:29
I'd like to change the text from ¨Cancel¨to ¨Done¨ of the Cancel button inside the UISearchBar in iOS 8. I am using UISearchController. I've tried different approaches for iOS 6 and iOS 7 and they do not work. Has anybody done this? Objective-C: [searchBar setValue:@"customString" forKey:@"_cancelButtonText"]; Swift: searchBar.setValue("customString", forKey:"_cancelButtonText") polo987 This worked for me in ios8, did not try in ios7, but should do the trick, beware of placing this line in the early times of the app cycle (eg : appDelegate) [[UIBarButtonItem appearanceWhenContainedIn:

TableView with SearchController - DEINIT not called

蹲街弑〆低调 提交于 2019-11-29 20:41:16
问题 I have added a search bar and search display controller from the interface builder to my app. I am not able to get it to deinit (dealloc) properly. It is showing the following behavior (swift2, ios9): User doesn't search anything, just selects an item from tableView, DEINIT is called User searches something (or just taps in the search bar), cancel the search, select item from tableView, DEINIT is called User searches something (or just taps the search bar), and selects an item from tableView,

How can I use queryStartingAtValue in my searchcontroller to search for users?

不问归期 提交于 2019-11-29 18:06:38
I have previously asked a question about searching for users the most cost-efficient way (without having to load up every user in the entire database. My code before the question was class FollowUsersTableViewController: UIViewController{ @IBOutlet var tableView: UITableView! private var viewIsHiddenObserver: NSKeyValueObservation? let searchController = UISearchController(searchResultsController: nil) var usersArray = [UserModel]() var filteredUsers = [UserModel]() var loggedInUser: User? // var databaseRef = Database.database().reference() //usikker på den koden over override func

iOS8 Cannot hide cancel button on search bar in UISearchController

萝らか妹 提交于 2019-11-29 16:24:26
问题 My goal is to prevent the cancel button from appearing in a search bar in a UISearchController. I started with Apple's Table Search with UISearchController sample code and hid the cancel button as seen in the code snip below. However, when the user taps in the text field, the cancel button still appears. Any help? override func viewDidLoad() { super.viewDidLoad() resultsTableController = ResultsTableController() searchController = UISearchController(searchResultsController:

UISearchController searchBar frame only resizes on first click

一曲冷凌霜 提交于 2019-11-29 15:34:37
I have just implemented a UISearchController in a regular UIViewController, and I have a kind of weird issue. I have a UIView that is adapted exactly to the size I want my UISearchBar to take. On first launch of the view, I add my UISearchBar as a SubView to this UIView. But when I launch it, the UISearchBar doesn't take the size of its parent UIView -- it just takes the width of the whole screen. As you can see, it overlaps with the button on the right. But once I click on the search bar and cancel it, it resizes to the exact size I want. What could be the issue here? I've tried adding

Cancel Button in UISearchController

别等时光非礼了梦想. 提交于 2019-11-29 05:35:27
In my project I'm using a UITableViewController with an internal UISearchController to filter the data in my tableView . I have no problem to filter the data but I need to make a date of my tableView reload when I click on the CANCEL button UISearchController but I can not find the delegate method for this ... Can you help me understand how to solve this problem? Gargoyle You need to set the UISearchController searchBar's delegate . Once you have done this, the addition of the delegate method searchBarCancelButtonClicked: will properly be called. self.searchController.searchBar.delegate = self

Display UISearchController's searchbar programmatically

核能气质少年 提交于 2019-11-29 04:22:15
Note 1: This question pertains to adding a UISearchController's search bar outside of the table view it updates - NOT as the table view's header. Note 2: Some trial and error led me to a solution. Please see my answer below. I am new to iOS development and am struggling to work with the UISearchController class. I have a view controller, and in my view controller's view, I plan to have a search bar above a table view. I would like the search bar to be linked to a UISearchController. Since interface builder does not come with a UISearchController, I am adding the controller programmatically.

UISearchController Search Bar Position Drops 64 points

青春壹個敷衍的年華 提交于 2019-11-29 04:11:42
The search bar is appearing exactly 64 points too low: All of the other frames are exactly correct. Edit: - It's the UISearchController 's view that is getting the wrong origin.y . It gets set to 64, when it should be 0. If I add this method: - (void)didPresentSearchController:(UISearchController *)searchController { [super didPresentSearchController:searchController]; searchController.view.frame = CGRectMake(0, 0, searchController.view.frame.size.width, searchController.view.frame.size.height); } Then the views align. However, its janky because it jumps. If I modify the frame in

UISearchController in a UIViewController

一世执手 提交于 2019-11-29 01:16:40
问题 I'm looking to create similar functionality to Apple's maps application in Swift. Is there anyway to integrate a UISearchController in to a regular view (i.e.: not a UITableView). Dropping one in through Storyboard results in a crash after clicking inside the connected searchbar. Or is there some way I can achieve this outcome with a UITableView? 回答1: I added a Search Bar and Search Display Controller in my View Controller in the storyboard. The view controller contains only the search bar