0
我需要关于如何做到这一点(最佳实践方法)的建议是:聊天屏幕/窗口布局设计
我使用的XCode 6.1.1使用斯威夫特与自动布局启用。 因此,在图片中,我已经设置了这种布局。 注意,在滚动视图,我把UITableView
连同另一UIView
它含有UITextField
它
我也已经实现了这一点:How to make a UITextField move up when keyboard is present?
因此,这里是我的代码:
func registerForKeyboardNotifications()
{
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardDidShow:", name: UIKeyboardDidShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardDidHide:", name: UIKeyboardDidHideNotification, object: nil)
}
func keyboardDidShow(aNotification: NSNotification)
{
var info: NSDictionary = aNotification.userInfo!
var kbSize: CGSize = (info.objectForKey(UIKeyboardFrameBeginUserInfoKey)?.CGRectValue() as CGRect!).size
var contentInsets: UIEdgeInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0)
svBody.contentInset = contentInsets
svBody.scrollIndicatorInsets = contentInsets
self.view.layoutIfNeeded()
}
func keyboardDidHide(aNotification: NSNotification)
{
var contentInsets: UIEdgeInsets = UIEdgeInsetsZero
svBody.contentInset = contentInsets
svBody.scrollIndicatorInsets = contentInsets
self.view.layoutIfNeeded()
}
的问题是当我运行它时,我还可以滚动我的viewBottom
后面的键盘,我不想那样。
我试图实现是:
- 我需要
viewBottom
粘在键盘的顶部 - 只有
myTable
可滚动
我怎样才能做到这一点最好的方式?