本文介绍了iPhone SDK:如何在方向更改后触发UIView子类上的drawRect?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在继承UIView并覆盖drawRect方法。我注意到只在视图首次加载时才调用视图的drawrect。之后再也不会被召唤了。如何确保在方向更改后调用它?我已经尝试在旋转之前和之后调用setNeedsDisplay,但是没有这样做。
I am subclassing a UIView and overwrite the drawRect method. I'm noticing that the view's drawrect is only being called when the view first loads. After that it is never called again. How to I make sure it gets called after an orientation change? I've tried calling setNeedsDisplay on the view before and after the rotation and that doesn't do it.
推荐答案
[myView setContentMode:UIViewContentModeRedraw];
你也可以在IB中设置它(即设置模式为重绘)
You can set this in IB as well (i.e., set mode to "redraw")
这篇关于iPhone SDK:如何在方向更改后触发UIView子类上的drawRect?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!