我正在为我的卡片应用程序实现一些简单的动画。等到动画块在赛前完成
到目前为止,一切工作都很顺利,但在完成之前我只有一个更多的细节需要解决。
的方案是非常简单的:前赛格瑞模态带来了新的屏幕
三卡必须与动画退出屏幕。
到目前为止,他的动画被执行并且新的视图被加载,但是我没有能够解决的细节是“等到动画完成之后才带来新视图”。
这是我怎么做:用这种方法
- (void)performExitAnimationWithCompletionBlock:(void (^)(BOOL))block
{
[UIView animateWithDuration:0.1f
delay:0.0f
options:UIViewAnimationOptionCurveEaseOut
animations:^
{
self.optionOneFront.center = self.optionOneBack.center = self.optionTwoFront.center;
self.optionOneFront.transform = self.optionOneBack.transform = self.optionTwoFront.transform;
self.optionThreeFront.center = self.optionThreeBack.center = self.optionTwoFront.center;
self.optionThreeFront.transform = self.optionThreeBack.transform = self.optionTwoFront.transform;
}
completion:^(BOOL finished)
{
CGPoint point = CGPointMake(self.optionTwoFront.center.x, self.view.frame.size.height * -2.0f);
[UIView animateWithDuration:1.0f
delay:0.0f
options:UIViewAnimationOptionCurveEaseOut
animations:^
{
self.optionOneFront.center = point;
self.optionOneBack.center = point;
self.optionTwoFront.center = point;
self.optionTwoBack.center = point;
self.optionThreeFront.center = point;
self.optionThreeBack.center = point;
}
completion:block];
}];
}
2)尝试呈现“AddOptions之前包裹动画中的SEGUE代码
1)设置退出动画“VC
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
[self performExitAnimationWithCompletionBlock:^(BOOL finished)
{
// Executes the following "if" statement if the user wants to add new options
if ([segue.identifier isEqualToString:@"AddOptions"])
{
UINavigationController *navigationController = segue.destinationViewController;
OptionsViewController *controller = (OptionsViewController *)navigationController.topViewController;
controller.delegate = self;
}
}];
}
正如我之前所说,一切正常,但模态窗口出现在动画完成之前。
任何想法我失踪?
嗨pdriegen,感谢您的回复。你的建议改进了实施,但主要问题依然存在。 performExitAnimationWithCompletionBlock没有完成,当segue进来。另外,我猜测,因为我在按钮方法中调用“AddOptions”,我可以将它从prepareForSegue中删除吗? “如果([segue.identifier isEqualToString:@”AddOptions“])”不再需要我想。 – 2012-08-02 08:40:37
@JuanGonzález:是的,我没有注意到seque将不得不在故事板中进行调整,以免自动启动。我还提供了一个替代解决方案,它不会在所有可能效果更好的情况下使用seques。请注意,我没有真正测试过这些... – pdriegen 2012-08-02 13:09:40
没关系。你的回答给了我需要解决的方向。谢谢! – 2012-08-02 15:59:29