FUISearchController

open class FUISearchController: UISearchController, FUIBarcodeScannerDelegate

Fiori style UISearchController. The only difference between FUISearchController and regular UISearchController is the searchBar. FUISearchController’s searchBar is FUISearchBar.

Developer can add a FUISearchBarcodeScanner to this FUISearchBar by setting the isBarcodeScannerEnabled property of the FUISearchBar to true. A barcode scanner icon will be displayed at the bookmark icon location of the search bar.

A barcode scanner view will be displayed when the barcode scanner icon is tapped.

Here is an sample code for an UITableViewController to add the FUISearchBar to its table view header.

   // Instantiate an FUISearchController and configure its properties
   searchController = FUISearchController(searchResultsController: nil)
   searchController.searchResultsUpdater = self
   searchController.hidesNavigationBarDuringPresentation = true
   searchController.searchBar.placeholderText = "Search The List"

   // Adding barcode scanner to this search bar
   searchController.searchBar.isBarcodeScannerEnabled = true
   searchController.searchBar.barcodeScanner?.scanMode = .EAN_UPC
   searchController.searchBar.barcodeScanner?.scanResultTransformer = { (scanString) -> String in
       return scanString.uppercased()
   }

   self.tableView.tableHeaderView = searchController.searchBar


  • Search bar of the search controller. When instantiating the FUISearchController programmatically, a default FUISearchBar is initialized automatically and can be used directly. The developer should set a reference to an @IBOutlet, if adding a search bar to their view in Interface Builder.

    Declaration

    Swift

    override open var searchBar: FUISearchBar
  • Handler for BarcodeScanner button (‘Bookmark button’) click

    Important

    Because the presentation of the view controller for barcode scanning is invoked internally when this method is called, this method will be invoked on the delegate only after the presentation of the view controller is completed.

    Parameter

    Parameter searchBar: calling UISearchBar

    Declaration

    Swift

    public func searchBarBookmarkButtonClicked(_ searchBar: UISearchBar)

    Parameters

    searchBar

    calling UISearchBar

  • Implement this method on your manual bar delegate when not managed by a UIKit controller. UINavigationBar and UISearchBar default to UIBarPositionTop, UIToolbar defaults to UIBarPositionBottom. This message will be sent when the bar moves to a window.

    Declaration

    Swift

    public func position(for bar: UIBarPositioning) -> UIBarPosition