我在正確處理鍵盤時遇到問題。Swift textfield - 決定視圖是否需要向上推
整個視圖充滿文本字段。
當我與工作的通知到移動視圖了上文本框不再可見:
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name:UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name:UIKeyboardWillHideNotification, object: nil)
}
func keyboardWillShow(sender: NSNotification) {
self.view.frame.origin.y -= 150
}
func keyboardWillHide(sender: NSNotification) {
self.view.frame.origin.y += 150
}
有一個你的想法選擇了哪個文本框(後面即將到來的如何區分鍵盤或鍵盤上方)來決定視圖是否必須推高?
感謝