UitextView AutoScroll to Last Line
-
05-07-2019 - |
문제
해결책
약간 다른 구현 (스크롤을 비활성화하고 싶습니다)이지만 UitextView에서 커서 점프를 중지해야했습니다. 이를 위해 UitextView 하위 클래스에서 Null ScrollRectTovisible을 구현했습니다. 이와 같이:
- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated
{
// do nothing. This fixes the cursor jumping above the field defect.
}
다른 팁
우수한 솔루션은 서브 클래스 UitextView 추가 라인에 있습니다
-(void) setContentOffset:(CGPoint)contentOffset {
[self setContentInset:UIEdgeInsetsZero];
[super setContentOffset:contentOffset];
}
일이야!
이것을 사용하십시오
NSRange myRange=NSMakeRange(outPutTextView.text.length, 0);
[outPutTextView scrollRangeToVisible:myRange];
내가 올바르게 이해하면 사용할 수 있습니다
[textView setScrollEnabled:NO];
스크롤을 비활성화합니다. 커서가 더 낮은 마진에 도달했을 때 입력하지 않아야하는 것은 어떻습니까? 아마도 좋은 솔루션은 아니지만 임계 값을 추가 할 수 있습니다 (최대 문자의 최대 문자 [textView text]
) 그리고 반환되지 않습니다
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
uitextView if의 대표 방법 [[textView text] length] > maxCharacters
.
속성 'ContentOffset'도 사용할 수있는 것 같습니다 ...
SetFrame의 마지막 줄이 있습니다.
- 당신은 할 수 있습니다 세트 프레임 약 라인 높이에
- 편집 할 때 - (bool)
textView:shouldChangeTextInRange:replacementText:
,사용scrollRangeToVisible:
, 논쟁은입니다selectedRange
- 편집을 종료하면 세트 프레임 원래 크기로
제휴하지 않습니다 StackOverflow