【发布时间】:2014-10-09 11:20:41
【问题描述】:
我已经实现了一个自定义 segue 类来模拟没有导航栏的推送转换。诀窍是拍摄快照,将它们添加到视图中,替换 viewController,移动快照,最后删除它们。这模拟了 viewController 的水平移动,但实际上只移动了两个 UIImagesView。
以下代码实现了这一点。
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];
}];
此代码适用于 iOS 7。但是,在使用 iOS 8 时,似乎没有执行动画。 destinationImageView 和 sourceImageView 直接移动到 finalPosition(WITHOUT ANIMATING)并且没有调用完成块,所以最终都没有移除 UIImageView。
有谁知道应该如何在 iOS 8 中执行动画?
【问题讨论】:
-
您是否启用了自动布局?您是否在情节提要中启用了尺寸等级?
-
看看这个问题,它可能对你有帮助:stackoverflow.com/questions/24472663/ios-8-animation-bug
标签: ios objective-c iphone animation quartz-core