iOS Developer Library — Pre-Release

Developer

UIKit Framework Reference UISearchController Class Reference

Options
Deployment Target:

On This Page
Language:

UISearchController

The UISearchController class defines an interface that manages the presentation of a search bar in concert with the search results controller’s content. The search results controller, a UIViewController object specified by the searchResultsController property, manages the results of the search. More...

Inheritance


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 8.0 and later.
  • Creates a new search controller using a search results controller that determines where search results are displayed.

    Declaration

    Swift

    init(searchResultsController searchResultsController: UIViewController!)

    Objective-C

    - (instancetype)initWithSearchResultsController:(UIViewController *)searchResultsController

    Parameters

    searchResultsController

    The UIViewController object that manages the search results.

    Return Value

    A search controller initialized with the given search results controller.

    Discussion

    Set the searchResultsController parameter to nil to display the search results in the same view that you are searching.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • active active Property

    The presented state of the search interface.

    Declaration

    Swift

    var active: Bool

    Objective-C

    @property(nonatomic, assign, getter=isActive) BOOL active

    Discussion

    When the user clicks in the search field of a managed search bar, the search display controller automatically displays the search interface. You can use this property to force the search interface to appear even if the user has not clicked in the search field.

    Setting this property to YEStrue performs a default presentation of the search controller appropriate for how the controller is configured. Implement the presentSearchController: method if the default presentation is not adequate for your purposes. The default is NOfalse.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • delegate delegate Property

    The search controller’s delegate.

    Declaration

    Swift

    unowned(unsafe) var delegate: UISearchControllerDelegate?

    Objective-C

    @property(nonatomic, assign) id< UISearchControllerDelegate > delegate

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Determines whether the underlying content is dimmed during a search.

    Declaration

    Swift

    var dimsBackgroundDuringPresentation: Bool

    Objective-C

    @property(nonatomic, assign) BOOL dimsBackgroundDuringPresentation

    Discussion

    Set this property to NOfalse if you are presenting the display results in the same view that you are searching. The default is YEStrue.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Determines whether the navigation bar is hidden during searching.

    Declaration

    Swift

    var hidesNavigationBarDuringPresentation: Bool

    Objective-C

    @property(nonatomic, assign) BOOL hidesNavigationBarDuringPresentation

    Discussion

    The default is YEStrue.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • searchBar searchBar Property

    The search bar object used by the search controller. (read-only)

    Declaration

    Swift

    var searchBar: UISearchBar { get }

    Objective-C

    @property(nonatomic, retain, readonly) UISearchBar *searchBar

    Discussion

    To create a custom UISearchBar, subclass the UISearchController class and return your custom object.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • The view controller that manages the results of the search. (read-only)

    Declaration

    Swift

    var searchResultsController: UIViewController! { get }

    Objective-C

    @property(nonatomic, retain, readonly) UIViewController *searchResultsController

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • The object responsible for updating the contents of the search results controller.

    Declaration

    Swift

    unowned(unsafe) var searchResultsUpdater: UISearchResultsUpdating?

    Objective-C

    @property(nonatomic, assign) id< UISearchResultsUpdating > searchResultsUpdater

    Discussion

    The object contained by the searchResultsUpdater property is often the view controller that is set during initialization. If you want to create your own updater object, set it to this property.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.