CS193P - 作业 3 - 仅在第一个 setNeedsDisplay 上调用 drawRect
我正在参加 CS193P iPhone 开发课程,即使..我知道我已经迟到了 与斯坦福大学的学生相比,我正在做作业 3。
我当前的问题是:我的 drawRect 方法并未在每次调用时都被调用 setNeedsDisplay...但仅限于第一个。
另外,我注意到我的多边形对象是 NULL(来自 多边形视图)。
这是我的项目的来源:
PolygonShape.h http://pastie.org/855503
PolygonShape.m http://pastie.org/855507
Controller.h http://pastie.org/855508
Controller.m http://pastie.org/855509
PolygonView.h http://pastie.org/855511
PolygonView.m http://pastie.org/855513
如果有人可以帮助我..我想这很简单,但我不能 好像找到了!
多谢! :)
I'm taking CS193P iPhone Development courses, and even if.. I know that I'm pretty late
comparing to Stanford's students, I'm doing Assignment 3.
My current problem is: My drawRect method does not get called on every
setNeedsDisplay... but only on the first.
Also, what I noted is that my polygon object is NULL (from
PolygonView).
Here are the sources of my project:
PolygonShape.h
http://pastie.org/855503
PolygonShape.m
http://pastie.org/855507
Controller.h
http://pastie.org/855508
Controller.m
http://pastie.org/855509
PolygonView.h
http://pastie.org/855511
PolygonView.m
http://pastie.org/855513
If someone could help me.. I guess this is pretty simple but I can't
seem to find it!
Thanks a LOT! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
drawRect:
不一定在每个setNeedsDisplay
上调用。调用
setNeedsDisplay
只会清除视图层的缓存。drawRect:
仅当屏幕实际刷新时才会被调用。因此,在运行循环恢复之前多次调用setNeedsDisplay
可能不会产生任何效果。drawRect:
is not necessarily called on everysetNeedsDisplay
.Calling
setNeedsDisplay
only clear the cache of the view's layer.drawRect:
will be called only when the screen is actually refreshed. So before the runloop resumes callingsetNeedsDisplay
multiple times may not have any effects.