Skip to content

Commit

Permalink
Fix Crash with gravity type in animation
Browse files Browse the repository at this point in the history
I didn't realize that getting `notification.notificationView`
was generating a new `UIView` instance on every call. This
passes in the current ones to the method that generates the animations
thus fixing the crash with gravity type in selected
  • Loading branch information
dmiedema committed Jan 16, 2015
1 parent cbe9c8a commit 14e9086
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions CRToast/CRToastManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ - (void)displayNotification:(CRToast*)notification {

notification.state = CRToastStateEntering;

[self showNotification:notification inwardAnimationBlock:inwardAnimationsBlock inwardCompletionAnimationBlock:inwardAnimationsCompletionBlock];
[self showNotification:notification notificationView:notificationView statusBarView:statusBarView inwardAnimationBlock:inwardAnimationsBlock inwardCompletionAnimationBlock:inwardAnimationsCompletionBlock];

if (notification.text.length > 0 || notification.subtitleText.length > 0) {
// Synchronous notifications (say, tapping a button that presents a toast) cause VoiceOver to read the button immediately, which interupts the toast. A short delay (not the best solution :/) allows the toast to interupt the button.
Expand All @@ -319,6 +319,8 @@ - (void)displayNotification:(CRToast*)notification {
}

- (void)showNotification:(CRToast *)notification
notificationView:(UIView *)notificationView
statusBarView:(UIView *)statusBarView
inwardAnimationBlock:(CRToastAnimationStepBlock)inwardAnimationsBlock
inwardCompletionAnimationBlock:(CRToastAnimationCompletionBlock)inwardAnimationsCompletionBlock {

Expand All @@ -338,12 +340,9 @@ - (void)showNotification:(CRToast *)notification
completion:inwardAnimationsCompletionBlock];
} break;
case CRToastAnimationTypeGravity: {
UIView *notificationView = notification.notificationView;
UIView *statusBarView = notification.statusBarView;

[notification initiateAnimator:_notificationWindow.rootViewController.view];
[notification.animator removeAllBehaviors];
UIGravityBehavior *gravity = [[UIGravityBehavior alloc]initWithItems:@[notificationView, statusBarView]];
UIGravityBehavior *gravity = [[UIGravityBehavior alloc] initWithItems:@[notificationView, statusBarView]];
gravity.gravityDirection = notification.inGravityDirection;
gravity.magnitude = notification.animationGravityMagnitude;
NSMutableArray *collisionItems = [@[notificationView] mutableCopy];
Expand Down

0 comments on commit 14e9086

Please sign in to comment.