在我的iOS应用程序中,我试图同时执行2个动画。但是,下面的代码不会做我想要的。它取消了第一个动画,并且只执行了第二个(通知中的一个)。至于第一个就是在1秒后达到最终结果。一个UIView动画取消了iOS中的另一个动画
dispatch_async(dispatch_get_main_queue(),^{
CGRect tempRect = CGRectMake(0, self.view.frame.size.height, toolbar.frame.size.width, toolbar.frame.size.height);
[UIView animateWithDuration: 1.0f
animations:^{
toolbar.frame = tempRect;
}
completion:^(BOOL finished) {
[toolbar setHidden: YES];
isPlayerToolbarActive = NO;
}];
});
[
[NSNotificationCenter defaultCenter] postNotificationName: @"animateSidePanels"
object: @"removingPlayerToolbar"];
// notification is sent here
-
(void) animateSidePanels: (NSNotification *) notification {
if ([notification.object isEqualToString: @"removingPlayerToolbar"]) {
[self.interactionsViewController performExtendAnimation: self.interactionsViewController.view.frame.size.height + 44
withDuration: 1.0f
completion:^(BOOL finished) {
}];
}
}
-(void)performExtendAnimation:(CGFloat)newHeight withDuration:(CGFloat)duration completion:(void (^)(BOOL finished))completion
{
[UIView animateWithDuration:duration animations:^{
CGRect newFrame = CGRectMake(self.view.frame.origin.x,
self.view.frame.origin.y,
self.view.frame.size.width,
newHeight);
self.view.frame = newFrame;
}completion: completion];
} 任何形式的帮助,高度赞赏!
“工具栏”和“self.interactionsViewController.view'有什么关系?我的猜测是,工具栏是交互控制器视图的子视图。是对的吗? – Tricertops