当用户在我的应用程序中使用屏幕键盘时,iOS导航栏会被隐藏。我该如何防止这种情况发生?当用户在搜索栏中或单击其中时,它都会发生。
我设法在用户单击取消或搜索/完成编辑后在搜索页面上显示导航栏,但搜索栏会被导航栏遮挡。
我在界面构建器中没有选择“如果键盘出现则隐藏栏”的选项。
请参考以下图片:
我设法在用户单击取消或搜索/完成编辑后在搜索页面上显示导航栏,但搜索栏会被导航栏遮挡。
我在界面构建器中没有选择“如果键盘出现则隐藏栏”的选项。
请参考以下图片:
试试这个,
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShowNotification:", name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHideNotification:", name: UIKeyboardWillHideNotification, object: nil)
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)
}
func keyboardWillShowNotification(notification: NSNotification) {
self.navigationController?.navigationBarHidden = false
}
func keyboardWillHideNotification(notification: NSNotification) {
self.navigationController?.navigationBarHidden = false
}
> NSDictionary* info = [note userInfo];
> CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
> UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height+80, 0.0);
> _scrollBackground.contentInset = contentInsets;
> _scrollBackground.scrollIndicatorInsets = contentInsets;