1

I ran into a behavior I don't understand yet. My code basically does this:

  • Create view with some custom UIView content (Views with drawRect), this view has no superview yet, so the Quartz subsytem dosen't call it's [layer display].

  • Then i do a renderInContext of the view.

  • The problem is that sometime the view is rendered perfectly, sometimes it does not render the subviews and it does not call their drawRect.

Why does it happen? I'm missing something. I actually know that the same layer can't be rendered simultaneously. But this view is not rendered on the main thread since it doesn't have a superview.

Thank you much

4

1 回答 1

0

非常有趣,没有看过源代码几乎是不可能理解的,但我得到了一些你可以使用的技巧。

  • 将视图添加到超级视图设置它的 alpha 为 0
  • 尝试将其添加到超级视图的范围之外
  • 尝试在该视图上调用 -setNeedsDiplay

我不知道它们是否有效,渲染系统不是一项简单的任务,但我会试一试。我没有得到的一件事,通常子视图被添加为子视图,但你说你用它们做一些事情在drawrect里面。不要在drawRect drawRect和addSubview中添加子视图:自定义绘图会影响哪些视图?

于 2013-06-06T14:59:31.553 回答