iPhone - setNeedsDisplay 不调用drawRect

发布于 2024-08-30 21:31:49 字数 135 浏览 4 评论 0原文

我看过很多关于这个问题的帖子,但没有得到答案。我有一个控制器,它将视图添加到主窗口。控制器的视图有一个子视图,该子视图有一个drawRect。问题是,即使我调用 [self setNeedsDisplay],这个函数也永远不会被调用。

谢谢

I have seen many posts about this problem but didn't get an answer. I have a controller which view is added to the main window. The controller's view has a subview which has a drawRect. The problem is that this function is never called even if I call [self setNeedsDisplay].

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寒江雪… 2024-09-06 21:31:49

它是 -(void)drawRect:(CGRect)rect 对吧?确保方法签名正确,并且即使不使用 rect 参数,也不要省略它。

-setNeedsDisplay 应该被称为子视图,而不是 self

另外,-setNeedsDisplay不会立即调用-drawRect:。它仅刷新图形缓存,以便在下一次更新帧时强制调用 -drawRect:

It is -(void)drawRect:(CGRect)rect right? Make sure the method signature is correct, and you don't omit the rect argument even if you don't use it.

-setNeedsDisplay should be called the the subview, not self.

Also, -setNeedsDisplay won't call -drawRect: immediately. It only flushes the graphics cache so that -drawRect: is forced to be called in the next update of the frame.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文