objective c. ScrollView: how to force it redraw visible part each time user scrolls?
I've got my own dynamically changing view inside scrollview.
As my view is very big I usually redraw only it's visible part.
But when I scroll up or down drawRect method isn't being called.
I guess scroll view has a buffer to quickly react on user actions but I don't know exactly a mechanism how it works.
UPD
Thanks to Wienke, I've got a solution: to implement UIScrollViewDelegate.
I've implemented scrollViewDidScroll method:
-(void) scrollViewDidScroll:(UIScrollView *)sender {
CGRect visibleRect;
visibleRect.origin = [scrollView contentOffset];
visibleRect.size = [scrollView bounds].size;
[textField setNeedsDisplayInRect:visibleRect];
}
So every time user scro开发者_StackOverflow社区lls even a little this method redraws the whole visible part. That's bad=(
How can I redraw only... Let me call that "new region that appeared after scrolling". I guess it's much faster...
Thanks for your attention.
Have you tried assigning a scrollview delegate? The UIScrollViewDelegate protocol includes methods like scrollViewDidEndDragging, upon which you could redraw.
精彩评论