IOS7이 되고 나서 텍스트 뷰에서 글 작성 할때 키보드로 글이 내려가 버리는 현상 발견 .. ~ ㅠㅠ
- (void)textViewDidChange:(UITextView *)textView {
CGRect line = [textView caretRectForPosition:
textView.selectedTextRange.start];
CGFloat overflow = line.origin.y + line.size.height
- ( textView.contentOffset.y + textView.bounds.size.height
- textView.contentInset.bottom - textView.contentInset.top );
if ( overflow > 0 ) {
// We are at the bottom of the visible text and introduced a line feed, scroll down (iOS 7 does not do it)
// Scroll caret to visible area
CGPoint offset = textView.contentOffset;
offset.y += overflow + 7; // leave 7 pixels margin
// Cannot animate with setContentOffset:animated: or caret will not appear
[UIView animateWithDuration:.2 animations:^{
[textView setContentOffset:offset];
}];
}
}
'Developer > IOS' 카테고리의 다른 글
UIWewView href control (0) | 2013.12.10 |
---|---|
IOS7 Stuatus Bar hidden (0) | 2013.11.27 |
자동 잠금,Auto Lock 제어 (0) | 2013.09.17 |
[IOS] IOS7 UInavigationBar (0) | 2013.09.12 |
버전정보 읽어오기 (0) | 2013.09.06 |