在我的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