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 trialIngo Ngoyama
4,882 PointsThere is no keyboardWill Show choice.
on the inter active app when we are making the key board the IDE does not show keyboardWillShow as an option to ViewController. . Is this a Swift 3.1 thing. As a matter of fact a key board does not show up on my app at all. It takes text from my laptop keyboard.
4 Answers
Jeff McDivitt
23,970 PointsAnd you have the functions written in your code
func keyboardWillShow(_ notification: Notification) {
if let info = notification.userInfo, let keyboardFrame = [UIKeyboardFrameEndUserInfoKey] as? NSValue {
let frame = keyboardFrame.cgRectValue
textFieldBottomConstraint.constant = frame.size.height + 10
UIView.animate(withDuration: 0.8) {self.view.layoutIfNeeded()
}
}
}
func keyboardWillHide(_ notification: Notification){
textFieldBottomConstraint.constant = 40
UIView.animate(withDuration: 0.8) { self.view.layoutIfNeeded() }
}
deinit {
NotificationCenter.default.removeObserver(self)
}
}
Ingo Ngoyama
4,882 PointsWhere is this located? Pasan said it was the system that will automatically put keyboard in the APP and there was no object for it. So I figured for some reason mine did not because it is the new 3.1. On his video he seemed surprised that the keyboard showed up by itself. It may have been a glitch or feature in 3.0. So because he got it automatically he never showed this code.
Ingo Ngoyama
4,882 PointsPasan said to set my simulator. I posted how to do it.
Ingo Ngoyama
4,882 PointsFOR ANY ONE ELSE WHO HAS THIS PROBLEM. Pasan let me know to go to the simulator and turn on the key board.
go to simulator menu and : hardware> simulator> keyboard> toggle software keyboard
(this is not code) This will make it display.
kols
27,007 PointsThanks — the keyboard wasn't showing up in the simulator for me, either...
Ben Moore
22,588 PointsHad the exact same issue. May be worth him adding a short cut-away clip or text on screen to notify students to look at a link to directions.
Xavier D
Courses Plus Student 5,840 PointsAlternately, the k keyboard command will work and avoid surfing thru the menus. You can also deselect the hardware keyboard option, but then that grays out software keyboard option.
IFANG LEE
4,894 PointsCancel this option in Simulator "Hardware>Keyboard>Connection HardWare Keyboard". the keyboard will show up !
Xavier D
Courses Plus Student 5,840 PointsHi
I think the k keyboard command while leaving Connection HardWare Keyboard enabled is better to display it because it can also make the keyboard not show if it's in the way. Canceling that connection hardware keyboard option grays out the option for the keyboard command.
XD
Jeff McDivitt
23,970 PointsJeff McDivitt
23,970 PointsDo you have
import UIKit
in your file?