scrollViewDidScroll 메서드에 텍스트 값 할당을 지정하면 효과가 있습니다.
샘플 조각 :
는 sample.h
...
@interface myRootUIViewController : UIViewController <UIScrollViewDelegate>
...
코멘트 : 그냥 유의 사항 : UIScrollViewDelegate 프로토콜을 잊지 마세요.
SAMPLE.m
- (void)viewDidLoad {
... whatever is created before and/or after...
NSString * text = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nunc semper lacus quis erat. Cras sapien magna, porta non,
suscipit nec, egestas in, arcu. Maecenas sit amet est.
Quisque felis risus, tempor eu, dictum ac, volutpat id,
libero. Ut gravida, purus vitae interdum elementum, tortor
justo porttitor nisi, id rhoncus massa.";
// calculate the required frame height according to defined font size and
// given text
CGRect frame = CGRectMake(0.0, 500.0, self.view.bounds.size.width, 1000.0);
CGSize calcSize = [text sizeWithFont:[UIFont systemFontOfSize:13.0]
constrainedToSize:frame.size lineBreakMode: UILineBreakModeWordWrap];
// for whatever reasons, contraintedToSize seem only be able to
// calculate an appropriate height if the input frame height is larger
// than required. Means: if your text requires height=250 and input
// frame height=100, then this method won't give you the expected
// result.
frame.size = calcSize;
frame.size.height += 0; // calcSize might be not pixel-precise,
// so add here additional padding pixels
UITextView * tmpTextView = [[UITextView alloc]initWithFrame:frame];
// do whatever adjustments
tmpTextView.backgroundColor = [UIColor blueColor]; // show area explicitly (dev
// purpose)
self.myTextView = tmpTextView;
self.myTextView.editable = NO;
self.myTextView.scrollEnabled = NO;
self.myTextView.multipleTouchEnabled = NO;
self.myTextView.userInteractionEnabled = NO; // pass on events to parentview
self.myTextView.font = [UIFont systemFontOfSize:13.0];
[tmpTextView release];
[self.scrollView addSubview:self.myTextView];
}
...
- (void)scrollViewDidScroll:(UIScrollView *)sender {
// for simplicity text is repeated again, of course it can be a member var/etc...
NSString * text = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nunc semper lacus quis erat. Cras sapien magna, porta non,
suscipit nec, egestas in, arcu. Maecenas sit amet est.
Quisque felis risus, tempor eu, dictum ac, volutpat id,
libero. Ut gravida, purus vitae interdum elementum, tortor
justo porttitor nisi, id rhoncus massa.";
self.myTextView.text = text; // assign value within this method and it is
// painted as expected.
}
코멘트 : 나는 분명히 샘플 인 이름과 값을 사용하여 소스 코드를 조정 한
. 다행히도 오타가 없습니다. 그러나 코드에는 텍스트 값이 변경 될 수 있으므로 실제로 다른 프레임 크기가 필요할 경우를 대비하여 텍스트의 필수 프레임 높이 계산이 포함되어 있습니다.
scrollViewDidScroll 메서드에 실제 텍스트 값 할당을 배치하면 스크롤하는 동안 깜박 거리지 않고 저에게 도움이되었습니다 (지금까지는 iPhone 시뮬레이터에서만 테스트되었습니다).
희망이 있습니다. 물론 나는이 isuse를 해결하기위한 건설적인 피드백, 개선 제안 또는 다른 방법에 대해서도 개방되어 있습니다.
답해 주셔서 감사합니다. 또한 UITextView가 UIScrollView의 하위 클래스이기 때문에이 버그가 UIWebView에서도 발생하기 때문에 버그가 있다고 생각합니다. 그러나이 방법을 사용하면 시스템은 일련의 단계 또는 명령을 표시하는 자연스러운 방법이므로 – muesan
동의하지만 버그라고 생각하지 않습니다. 기능입니다. 나는 애플이 이것을 피할 방법이 없다. –