简体   繁体   English

如何防止UIView动画进行子视图自动调整大小操作?

[英]How to prevent UIView animation for subview auto-resize operations?

I use 我用

[UIView beginAnimations:nil context:NULL];

to animate a UIViewController 's frame. UIViewController的框架设置动画。 That view controller includes a UITableView and that UITableView 's cells are custom subview which also has autoresizing mask set. 该视图控制器包括一个UITableView ,并且UITableView的单元格是自定义子视图,该子视图还具有自动调整大小的掩码集。

While animating the parent viewcontroller, changes in frame causes animation also for that cell contents which is expected but not what I wanted. 在为父级ViewController设置动画时,帧中的更改也会使该单元格内容产生动画,这是预期的,但不是我想要的。 I want those cells to immediately set their new frame and I want the whole viewcontroller content to move (animate) as a block, not as independent objects. 我希望这些单元格立即设置其新框架,并且我希望整个viewcontroller内容作为一个块而不是作为独立对象移动(动画)。

I can not specifically set frame for inner contents as this is not the single viewcontroller. 我不能专门为内部内容设置框架,因为这不是单个viewcontroller。 There are 7 viewcontrollers which are animated (sliding animation) 有7个具有动画效果(滑动动画)的视图控制器

PS: I am not looking for an alternative component for transition of viewcontrollers, as I am doing custom animation. PS:我在做自定义动画时,没有在寻找视图控制器过渡的替代组件。

Is there a way to stop animations for autoresizing operations for a specific UIView or UIViewController? 有没有一种方法可以停止动画以自动调整特定UIView或UIViewController的大小?

Update 更新

Using transitionWithView still causes subviews to animate with autoresizing. 使用transitionWithView仍会使子视图具有自动调整大小的动画。 Stack trace: 堆栈跟踪:

+[UIView(UIViewAnimationWithBlocks) transitionWithView:duration:options:animations:completion:] ()
+[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] ()
-[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] ()
-[UIView(Geometry) setFrame:] ()

Ok. 好。 Here my insane thoughts: 这是我疯狂的想法:

1) Add all subviews to array 1)将所有子视图添加到数组

2) Remove all subviews from superview 2)从超级视图中删除所有子视图

3) Create new view same size as old and make her transparent 3)创建与旧大小相同的新视图并使她透明

4) Add all subviews from array to new view 4)将所有子视图从数组添加到新视图

5) Apply animation to new view with duration 0 (subviews will resize immediately) 5)将动画应用于持续时间为0的新视图(子视图将立即调整大小)

6) Apply animation to old view with you need duration 6)根据需要将动画应用于旧视图

7) Move subviews back to old view when animation from step 6 did ended 7)步骤6的动画结束后,将子视图移回旧视图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM