Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Luke Glazebrook
13,564 PointsDismissing Keyboard on iOS Simulator.
Hey guys.
So I am currently working on an App for the iPhone and when I click on the text field to type in what I want the keyboard comes up but then once its there I cannot get it to go away.
I have tried setting the return key to "Done" in the attribute inspector but that button doesn't appear on the keyboard and I cannot seem to figure out why it isn't working.
Any help would be much appreciated guys!
-Luke
2 Answers
jean-marie castellucci
4,954 PointsIt will just hide the keyboard.
If you want to hide the keyboard on your app after a tap just do this :
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
yourTextField.resignFirstResponder()
}
In the viewDidLod :
yourTextField.delegate = self
jean-marie castellucci
4,954 PointsTry cmd + K
Luke Glazebrook
13,564 PointsWhat does this shortcut do?
Also, will this allow the keyboard to be dismissed in the app on an actual device?
-Luke