gpt4 book ai didi

ios - 如何在不将views设置为零的情况下进行水平翻转动画?

转载 作者:行者123 更新时间:2023-11-29 03:41:45 24 4
gpt4 key购买 nike

我正在 UIViewController 内的 map 和 ListView 之间进行“标准”翻转,顶部有导航栏,那里有一个按钮可以在 map 显示和列表之间切换。我正在使用此方法执行转换:

    [UIView transitionFromView:self.tableView
toView:self.mapView
duration:1
options:UIViewAnimationOptionTransitionFlipFromLeft
completion:nil];

但是完成后,“从 View ”为零,再切换一次后,两个 View 都为零。还有另一种方法可以在 View 之间切换并保留两者吗?然后我就不必在显示时再次填充和初始化它们。每次用户翻转时,对带有大量图钉的 map 执行此操作有点糟糕。

最佳答案

来自documentation :

fromView

The starting view for the transition. By default, this viewis removed from its superview as part of the transition.

toView

The ending view for the transition. By default, this view is added to thesuperview of fromView as part of the transition.

Discussion

This method provides a simple way to transition from theview in the fromView parameter to the view in the toView parameter. Bydefault, the view in fromView is replaced in the view hierarchy by theview in toView. If both views are already part of your view hierarchy,you can include the UIViewAnimationOptionShowHideTransitionViewsoption in the options parameter to simply hide or show them.

因此,如果您还没有将这两个 View 作为 View 层次结构的一部分,为什么不提前添加它们呢?您可以将 mapview 作为 subview 插入到 tableView 下面(这样它一开始不会显示),然后使用 UIViewAnimationOptionShowHideTransitionViews 沿着 UIViewAnimationOptionTransitionFlipFromLeft 作为选项。

关于ios - 如何在不将views设置为零的情况下进行水平翻转动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18329763/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com