0
키보드 쇼에서 UITextView의 크기를 조정하려고합니다. 그러나 아래 코드는 이상하게 작동합니다. 텍스트보기는 새 높이로 점프 한 다음 원래 높이로 다시 애니메이션합니다. 여기에 어떤 도움을 주시면 감사하겠습니다.UITextView의 높이 조절 애니메이션
//Handles keyboard appearance
func keyboardWillShow(notification:NSNotification){
var rightButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self, action: Selector("dismissKeyboard"))
self.navigationItem.rightBarButtonItem = rightButton
self.origNoteFrame = notes.frame
var duration = NSTimeInterval((notification.userInfo![UIKeyboardAnimationDurationUserInfoKey] as NSNumber).intValue)
var options = UIViewAnimationOptions(
UInt((notification.userInfo![UIKeyboardAnimationCurveUserInfoKey] as NSNumber).integerValue << 16)
)
UIView.animateWithDuration(
duration,
delay: 0.0,
options: options,
animations: {
self.notes.frame = CGRectMake(self.notes.frame.origin.x, self.notes.frame.origin.y, self.notes.frame.width, (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue().origin.y - 10)
},
completion: nil)
}
내가 당신의 코드를 실행하고 나는 그런 행동이 (오히려 또 다른 문제는 여기에 언급이 표시되지 않습니다 http://stackoverflow.com/questions/26004080/keyboardwillshow-will-only-work-from-the-second -time-on. 애니메이션을 사용하지 않고, 단순히'self.notes.frame = CGRectMake (self.notes.frame.origin.x, self.notes.frame.origin.y, self.notes.frame. 너비는 (notification.userInfo? NSValue로 UIKeyboardFrameEndUserInfoKey) .CGRectValue(). origin.y - 10)'? – abinop
@abinop 예, 그렇습니다. 높이가 여전히 원래 높이로 돌아갑니다. – steventnorris