我有一个view
个应用,我有- top space 0 to MapView
- trailing and leading 0
- bottom: 49 to superview (it's embedded in tab controller so with value 49 it's exactly above the tab controls)
嵌入式textView
。
看起来像这样:
我的- leading, bottom, top 4 to view border
- trailing 8 to button
- height 30
位于地图下方,因此它有约束条件:
textView
textView
有标准约束:
func keyboardWillChangeFrame(notification: NSNotification) {
let endFrame = (notification.userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
if(isKeyboardShown == true)
{
bottomConstraint.constant = CGRectGetHeight(view.bounds) - endFrame.origin.y+49
self.view.layoutIfNeeded()
isKeyboardShown = false
} else {
//scrollToBottom()
bottomConstraint.constant = CGRectGetHeight(view.bounds) - endFrame.origin.y
self.view.layoutIfNeeded()
isKeyboardShown = true
}
}
当我运行应用程序时,一切都很好,我看到地图,我看到它下面的bottomConstraint
。当我开始在IBOutlet
中输入内容时,键盘就会出现问题(感谢:
=0
,其中textView
是func textViewDidChange(textView: UITextView) {
let fixedWidth = textView.frame.size.width
textView.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat.max))
let newSize = textView.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat.max))
var newFrame = textView.frame
newFrame.size = CGSize(width: max(newSize.width, fixedWidth), height: newSize.height)
textView.frame = newFrame
}
的底部约束(textView
)的textView
。无论如何,我添加了这个方法:
textView
我希望textView
改变它的大小。它正在发生,但view
扩展到底部 - 我的意思是当用户开始编写多行时,view
部分位于键盘下,而不是覆盖越来越多的地图部分。更重要的是,在下降时,textView
会超过灰色view
- 因此HomeKit
本身不会扩展。
如何解决这个问题,以便HomeKit
和print(accessory.services.count)
成长为每一个新行覆盖越来越多的地图?我不希望它部分隐藏在键盘下面。