iPhone SDK:如何在方向改变后触发 UIView 子类上的 drawRect? [英] iPhone SDK: How to trigger drawRect on UIView subclass after orientation change?

查看:14
本文介绍了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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆