开发者

objective c. ScrollView: how to force it redraw visible part each time user scrolls?

开发者 https://www.devze.com 2023-02-21 20:45 出处:网络
I\'ve got my own dynamically changing view inside scrollview. As my view is very big I usually redraw only it\'s visible part.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消