renderInContext 无法渲染宽度大于 512 像素的 UIView

发布于 2025-01-01 12:05:26 字数 441 浏览 1 评论 0原文

我有一个宽度超过 600 像素的视图层次结构。在该层次结构中,我有一个 UITextView。一切都正确显示在屏幕上。

然后,我尝试从该视图创建图像:

CGSize size = mainView.bounds.size;
UIGraphicsBeginImageContextWithOptions(size, YES, 1.0);
[[mainView layer] renderInContext:UIGraphicsGetCurrentContext()];

这在大多数情况下都有效。

但是,如果 UITextView 宽度超过 512 像素,则不会绘制文本。视图本身是可见的(您可以看到背景),但没有文本。

这是 OS4 和 OS5 上的。

我认为这是一个错误,但我迫切需要一个解决方法。有人见过这个吗?

蒂姆

I have a view hierarchy that's over 600 pixels wide. Inside that hierarchy I have a UITextView. Everything displays correctly on screen.

I then try to create an image from that view:

CGSize size = mainView.bounds.size;
UIGraphicsBeginImageContextWithOptions(size, YES, 1.0);
[[mainView layer] renderInContext:UIGraphicsGetCurrentContext()];

This works for the most part.

However, if the UITextView is wider than 512 pixels then the text isn't drawn. The view itself is visible (you can see the background), but there's no text.

This is on OS4 and OS5.

I assume that this is a bug, but I desperately need a workaround. Has anyone see this before?

Tim

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

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

发布评论

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

评论(1

唯憾梦倾城 2025-01-08 12:05:26

我现在已经解决了这个问题。这是一个奇怪的 iOS 错误,在以下情况下会引发:

  1. 文本视图的超级视图之一未完全包含在其视图中
    父视图。
  2. 文本视图的宽度超过 512

像素

I've now fixed this. It's a curious iOS bug that's provoked when:

  1. one of the text view's superviews isn't fully contained within its
    parent view.
  2. the text view is over 512 pixels wide

Tim

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