setNeedsDisplay setNeedsLayout layoutIfNeeded

1. [self.scrollView layoutIfNeeded];

//Lays out the subviews immediately.此方法立即执行 

下面的方法有点像 不是立即执行而是在下一个drawing cycle update中一起更新

2. [self.scrollView setNeedsLayout];

//Because this method does not force an immediate update


3. [self.scrollView setNeedsDisplay];

self.scrollView.contentSize = CGSizeMake(self.view.size.width,maxH);

这是为了缓冲一下,要刷新的view都放在一起刷新 ,避免浪费性能。

setNeedsDisplay调用drawRect绘制


4.还有就是在view中layoutsubviews,

//实现这个方法来直接设置子控件的frame (适合于自定意义view)

   [scrollViewlayoutSubviews];

//Subclasses can override this method as needed to perform more precise layout of their subviews.

 You should not call this method directly.


 参考文章:http://blog.csdn.net/xie_kun/article/details/7270546  



你可能感兴趣的:(setNeedsDisplay setNeedsLayout layoutIfNeeded)