0
我有一個UITextView覆蓋故事板中的整個視圖控制器設置。頂部佈局指南,底部佈局指南,前緣和後緣都有限制。UITextView中不需要的滾動空間
我已經註冊鍵盤的通知,調整內容的插圖是這樣的:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardAppeared:)
name:UIKeyboardDidShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardDisappeared:)
name:UIKeyboardDidHideNotification
object:nil];
keyboardAppeared的實現:
- (void)keyboardAppeared:(NSNotification *)notification {
NSDictionary *notificationUserInfo = [notification userInfo];
CGRect keyboardRect = [[notificationUserInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
self.textView.contentInsets = UIEdgeInsetsMake(0, 0, keyboardRect.heignt, 0);
self.textView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, keyboardRect.height, 0);
}
keyboardDisappeared的實現:
- (void)keyboardDisappeared:(NSNotification *) {
self.textView.contentInsets = UIEdgeInsetsZero;
self.textView.scrollIndicatorInsets = UIEdgeInsetsZero;
}
這裏的問題是,當鍵盤出現在tex中有不需要的滾動tView如果textView文本較少。當文字大小超過textView高度時,不需要的滾動不會出現。
請幫忙!
看到這個答案http://stackoverflow.com/questions/25782352/what-is-causing-this-unwanted- content-inset-with-uitextview -in-ios-8-not-there – Deepesh 2014-11-25 07:15:06
鏈接沒有幫助。在文本結尾處我獲得了額外的空間。我已經自動將AdjustScrollViewInsets切換到NO。 – Tarun 2014-11-25 07:47:11