我有两个textfields和一个Image pickerView按钮的tableview。
如果我写的东西,我的文字区域正在增加,没关系。
但是,如果我从我的imagePicker视图中选择照片并尝试写一些东西,我就看不到我的文本字段了。请帮忙。
答案 0 :(得分:0)
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name: UIKeyboardDidShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name: UIKeyboardDidHideNotification, object: nil)
}
deinit {
NSNotificationCenter.defaultCenter().removeObserver(self)
}
func keyboardWillShow(notification: NSNotification) {
if let userInfo = notification.userInfo {
if let keyboardHeight = userInfo[UIKeyboardFrameEndUserInfoKey]?.CGRectValue.size.height {
tableView.contentInset = UIEdgeInsetsMake(0, 0, keyboardHeight, 0)
}
}
}
func keyboardWillHide(notification: NSNotification) {
if let userInfo = notification.userInfo {
tableView.contentInset = UIEdgeInsetsMake(50, 0, 0, 0)
}
}