简体   繁体   中英

UIView animateWithDuration not animating in ios8

I have implemented a custom segue class for emulating the push transition without navigation bar. The trick is to take to snapshots, add them to the view, replace the viewController, move the snapshots, and finally remove them. This emules a horizontal movement of the viewController, but actually only two UIImagesView are moved.

The following code implements this.

self.destinationImageView.frame = offsetFrameD;
self.sourceImageView.frame = offsetFrameS;

//ViewController replacement
[self.sourceViewController presentModalViewController:self.destinationViewController animated:NO];

//Overpose the snapShot who will simulate the transition between vies.
[destinationView addSubview: self.sourceImageView];
[destinationView addSubview: self.destinationImageView];

[UIView animateWithDuration:1.0
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseOut
                 animations:^{
                     self.destinationImageView.frame = self.finalFrameD;
                     self.sourceImageView.frame = self.finalFrameS;
                 }
                 completion:^(BOOL finished) {
                     [self.sourceImageView removeFromSuperview];
                     [self.destinationImageView removeFromSuperview];
                 }];

This code worked with iOS 7. However, when using iOS 8, it seems like the animation is not performed. The destinationImageView and sourceImageView are directly moved to the finalPosition (WITHOUT ANIMATING) and the completion block is not called, so both UIImageView are not finally removed.

Does anyone knows how the animation should be performed with iOS 8?

You should adjust the auto layout constraints and not the frames position. Have a look at this solution. I hope it helps. UIView transitionWithView & setting the frame no longer works iOS8

在动画开始之前,使用以下代码行:

[UIView setAnimationsEnabled:YES];

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