在视图交换期间,UITableView 在 setAnimationTransition 之前显示扭曲

发布于 2024-07-30 01:57:37 字数 1167 浏览 3 评论 0原文

问候! 我试图借用 Apple 的 TheElements 示例应用程序中的视图翻转概念。 此示例使用容器 UIView,您可以在其中在两个子视图之间交换。 翻转是使用 setAnimationTransition:forView:cache: 并删除/添加每个子视图来实现的。

一般来说,翻转有效,我可以在两个视图之间交换(带有页眉/页脚的 UITableViewMKMapView)。 但是,在翻转表视图之前和之后,我的表视图的各个(一致选择的)区域被删除(使用表视图的背景颜色),我不明白为什么。

我在绘图方面找不到表格视图的任何异常之处。 在示例应用程序的情况下,视图是从头开始绘制的,但我希望这不会影响它! 我真的希望它很简单 - 也许是 UITableView 属性设置?

线索表示赞赏。 谢谢!

更新:当我放慢动画速度时,我开始了解受到干扰的内容(尽管我仍然不知道为什么)。 我的表头视图包含图像视图和标签视图。 现在,想象一下这两个视图的 CGRect(仅没有任何可见内容,只有背景颜色)在表格视图中进一步重绘,位于表格行上方

这种情况也会发生在另一块房地产上,该房地产似乎来自设置了自定义高度(以调整其中文本大小)的表格视图单元格。

我在整个代码中无缘无故地放置了许多断点(在这些断点中,事物的大小、创建等等),并且在转换过程中没有一个断点被击中。

我什至尝试将表视图放置在 UIView 中,并将其作为过渡目标。 没有不同。

来自 API 文档:

缓存可以提高性能,但是如果 您将此参数设置为 YES,您 不得更新视图或其 过渡期间的子视图。 更新视图及其子视图可能 干扰缓存行为 并导致视图内容成为 渲染不正确(或者错误地渲染) 位置)在动画期间。 你 必须等到转换结束 更新视图。

这一切都很好,但在过渡期间我不会更新任何视图或子视图。 (至少不是故意的!再次,请参阅有关断点的注释。没有任何内容被击中。)

Greetings! I'm trying to borrow the view flip concept from Apple's TheElements sample app. This sample employs a container UIView in which you can swap between two subviews. The flip is achieved using setAnimationTransition:forView:cache: and removing/adding each subview.

In general, the flip works and I can swap between my two views (a UITableView with headers/footers, and a MKMapView). However, various (consistently chosen) areas of my table view are obliterated (using the table view's background color) before and after the table view is flipped, and I don't understand why.

I can't find anything unusual about the table view in terms of drawing. In the case of the sample app, the view is drawn from scratch, but I would hope that doesn't factor in to it! I'm really hoping it's something simple - maybe a UITableView property setting?

Clues appreciated. Thanks!

Update: When I slow down the animation, I begin to get an understanding of what is being disturbed (though I still don't know why). My table header view contains an image view and label view. Now, imagine the CGRects for those two views (only without any visible content, just a background color) being redrawn further down the table view, right over the table rows.

This also happens with another chunk of real estate that appears to come from a table view cell that was set with a custom height (to size the text within it).

I dropped a gratuitous number of breakpoints throughout my code (where things are sized, created and whatnot), and not one of them is hit during the transition.

I even tried placing my table view inside a UIView and targeting that for the transition instead. No difference.

From the API docs:

Caching can improve performance but if
you set this parameter to YES, you
must not update the view or its
subviews during the transition.
Updating the view and its subviews may
interfere with the caching behaviors
and cause the view contents to be
rendered incorrectly (or in the wrong
location) during the animation. You
must wait until the transition ends to
update the view.

That's all well and good, but I'm not updating any views or subviews during the transition. (At least not on purpose! Again, see the note about the breakpoints. Nothing got hit.)

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

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

发布评论

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

评论(1

何止钟意 2024-08-06 01:57:37

惊人的。

答案:在这种情况下,它似乎只发生在......模拟器中! 在设备上,这很好。

我认为这种普通的过渡将在模拟器和设备上呈现相同的效果。

我错了。 因此,如果您在模拟器上看到动画过渡故障,请坚持下去。 或许终究会好起来。

Amazing.

Answer: In this case, it appears to only happen in ... the Simulator! On the device, it's fine.

I was thinking that such a run-of-the-mill transition would be the sort of thing that would render identically on the Simulator and the device.

I was wrong. So if you ever see animation transition glitches on the simulator, hang in there. It might be fine after all.

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