Last active
January 9, 2018 23:35
-
-
Save arabdevteam/756371cec78c1ef7af0b0e4f0b0c551f to your computer and use it in GitHub Desktop.
How to type url directly in UITextField without "http://".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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