Skip to content

Instantly share code, notes, and snippets.

@arabdevteam
Created November 29, 2017 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arabdevteam/bb1bef0d8632b6eb5edc592522255959 to your computer and use it in GitHub Desktop.
Save arabdevteam/bb1bef0d8632b6eb5edc592522255959 to your computer and use it in GitHub Desktop.
// creating a function to enable our textField to load the webView with new requests and this function used specifically to use search key as a search button..
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
let url = URL(string: textField.text!) // assigning textField value to url
let request = URLRequest(url: url!) // making a request based on textField input text
myWeb.loadRequest(request) // loading webView with the request
textField.text = url?.relativeString // updating TextField with url string
textField.resignFirstResponder() // keyboard dismissal upon clicking search key
return true // search key as a search button
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment