@@ -34,6 +34,7 @@ import UIKit
34
34
self . searchBar!. barTintColor = . white
35
35
self . searchBar!. delegate = self
36
36
self . searchBar!. placeholder = " Search for place " ;
37
+ self . searchBar!. showsCancelButton = true
37
38
}
38
39
self . navigationItem. titleView = searchBar
39
40
setupTableview ( )
@@ -52,29 +53,14 @@ import UIKit
52
53
}
53
54
extension GoongAutocompleteViewController : UISearchBarDelegate {
54
55
public func searchBarCancelButtonClicked( _ searchBar: UISearchBar ) {
55
- self . cancelSearching ( )
56
- searchActive = false ;
56
+ self . navigationController? . dismiss ( animated: true , completion: nil )
57
57
}
58
58
59
59
public func searchBarSearchButtonClicked( _ searchBar: UISearchBar ) {
60
60
self . view. endEditing ( true )
61
61
searchBar. searchTextField. resignFirstResponder ( )
62
62
}
63
63
64
- public func searchBarTextDidBeginEditing( _ searchBar: UISearchBar ) {
65
- self . searchBar!. setShowsCancelButton ( true , animated: true )
66
- }
67
-
68
- public func searchBarTextDidEndEditing( _ searchBar: UISearchBar ) {
69
- self . searchBar!. setShowsCancelButton ( false , animated: false )
70
- }
71
-
72
- func cancelSearching( ) {
73
- searchActive = false ;
74
- self . searchBar!. resignFirstResponder ( )
75
- self . searchBar!. text = " "
76
- }
77
-
78
64
public func searchBar( _ searchBar: UISearchBar , textDidChange searchText: String ) {
79
65
NSObject . cancelPreviousPerformRequests ( withTarget: self , selector: #selector( self . search) , object: nil )
80
66
self . perform ( #selector( self . search) , with: nil , afterDelay: 0.5 )
0 commit comments