tim tim - 1 year ago 61
iOS Question

searchBarSearchButtonClicked not working IOS

I am trying to use the search bar to print out a string but the delegate function i have written does not work and I really do not understand where I am going wrong. Please can someone advise?

class LandingPage: UIViewController, UISearchBarDelegate{

func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
print("search bar button clicked! ")

Answer Source

If you have added the search bar in storyboard then you have to ctrl+drag to ViewController the yellow button and select search bar delegate. if you have created the search bar in code then you have to assign it's delegate in your viewcontroller.swift

searchbar.delegate = self
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download