UISearchController: show results even when search bar is empty

前端 未结 14 2267
独厮守ぢ
独厮守ぢ 2020-12-23 13:27

As I understand, the default behaviour of UISearchController is:

  1. On tapping search bar, background is dimmed and \'cancel\' button is shown.
14条回答
  •  旧巷少年郎
    2020-12-23 13:43

    The easiest way is to use ReactiveCocoa with this extension https://github.com/ColinEberhardt/ReactiveTwitterSearch/blob/master/ReactiveTwitterSearch/Util/UIKitExtensions.swift

            presentViewController(sc, animated: true, completion: {
                sc.searchResultsController?.view.rac_hidden.modify({ value -> Bool in
                    return false
                })
            } )
    

    where sc is your UISearchController

提交回复
热议问题