0
我的LoginViewController有一个UIView有2个UItextfield和1个UIbutton。用户开始写UIView的时刻应该上去,为键盘留出空间。但是,我的问题是,当键盘消失UIView没有在其初始位置。谁能帮我请谢谢...(我的代码如下)UIview继续在UIViewcontroller的底部
func keyboardON(sender: NSNotification) {
let info = sender.userInfo!
var keyboardSize = info[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue().size
println("keyboard height \(keyboardSize.height)")
var frame = otherContainerView.frame
println("MainScreen :\(UIScreen.mainScreen().bounds.height)")
frame.origin.y = UIScreen.mainScreen().bounds.height - keyboardSize.height - frame.size.height
otherContainerView.frame = frame
}
func keyboardNotOn(sender: NSNotification) {
let info = sender.userInfo!
var keyboardSize = info[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue().size
println("keyboard height \(keyboardSize.height)")
var frame = otherContainerView.frame
frame.origin.y = UIScreen.mainScreen().bounds.height - frame.size.height
otherContainerView.frame = frame
}
我已经更新了我的回复,以更多地解释为什么您尝试实施的方法比它可能更难。 –
在您的main.storyboard中,您需要拖出一个UITableViewController并将其设置为LoginTableViewController类型。一旦你这样做,确保细胞是静态的。添加你的UITextFields和你的UIButton。然后将您的文本框和按钮连接到上面找到的IBOutlets。这就是你应该做的。 –
如果您的单元格是动态的,则只需设置cellForRowAtIndexPath。但是,你会希望它们是静态的。 –