简体   繁体   中英

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

I use

[UIView beginAnimations:nil context:NULL];

to animate a UIViewController 's frame. That view controller includes a UITableView and that UITableView 's cells are custom subview which also has autoresizing mask set.

While animating the parent viewcontroller, changes in frame causes animation also for that cell contents which is expected but not what I wanted. 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.

I can not specifically set frame for inner contents as this is not the single viewcontroller. There are 7 viewcontrollers which are animated (sliding animation)

PS: I am not looking for an alternative component for transition of viewcontrollers, as I am doing custom animation.

Is there a way to stop animations for autoresizing operations for a specific UIView or UIViewController?

Update

Using transitionWithView still causes subviews to animate with autoresizing. 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

2) Remove all subviews from superview

3) Create new view same size as old and make her transparent

4) Add all subviews from array to new view

5) Apply animation to new view with duration 0 (subviews will resize immediately)

6) Apply animation to old view with you need duration

7) Move subviews back to old view when animation from step 6 did ended

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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