UIView animateWithDuration未在ios8中设置动画
我实现了一个自定义segue类,用于模拟没有导航栏的推送转换。诀窍是获取快照,将它们添加到视图中,更换viewController,移动快照,最后删除它们。这将使viewController水平移动,但实际上只移动两个UIImagesView 下面的代码实现了这一点UIView animateWithDuration未在ios8中设置动画,ios,objective-c,iphone,animation,quartz-core,Ios,Objective C,Iphone,Animation,Quartz Core,我实现了一个自定义segue类,用于模拟没有导航栏的推送转换。诀窍是获取快照,将它们添加到视图中,更换viewController,移动快照,最后删除它们。这将使viewController水平移动,但实际上只移动两个UIImagesView 下面的代码实现了这一点 self.destinationImageView.frame = offsetFrameD; self.sourceImageView.frame = offsetFrameS; //ViewController replace
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];
}];
这段代码适用于iOS7。但是,在使用iOS 8时,似乎没有执行动画。destinationImageView和sourceImageView会直接移动到最终位置,而无需设置动画,并且不会调用完成块,因此不会最终删除这两个UIImageView
有人知道iOS 8应该如何执行动画吗 您应该调整自动布局约束,而不是框架位置。看看这个解决方案。我希望有帮助。
您应该调整自动布局约束,而不是框架位置。看看这个解决方案。我希望有帮助。
在动画开始之前使用以下代码行:
[UIView setAnimationsEnabled:YES];
在动画开始之前使用以下代码行:
[UIView setAnimationsEnabled:YES];
是否启用了自动布局?您是否在故事板中启用了大小类?看看这个问题,它可能会帮助您:是否启用了自动布局?您是否在故事板中启用了大小类?看看这个问题,它可能会帮助您:在开始动画之前使用这一行代码编写这一行代码。[UIView SetAnimationEnabled:YES];[UIView animateWithDuration:3.0动画:^{}完成:^BOOL完成{}];在开始动画之前使用这行代码编写这行代码。[UIView SetAnimationEnabled:YES];[UIView animateWithDuration:3.0动画:^{}完成:^BOOL完成{}];