Skip to content

Instantly share code, notes, and snippets.

@arabdevteam
Last active January 9, 2018 23:35
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/756371cec78c1ef7af0b0e4f0b0c551f to your computer and use it in GitHub Desktop.
Save arabdevteam/756371cec78c1ef7af0b0e4f0b0c551f to your computer and use it in GitHub Desktop.
How to type url directly in UITextField without "http://".
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
let url = URL(string: "http://\(textField.text!)") // assigning textField value to url & enable user to write url without the need to "http://"
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