Am trying to do this animation on a view, To Scale it to (0,0) then Move this frame using CGRectMake method and scale it back to (1,1). So I used the following Code to do this
-(void)startWalkAnimationStartWalkingBtnViewScaleToZero{
CGAffineTransform transform = StartWalkBtnView.transform;
StartWalkBtnView.transform=CGAffineTransformScale(transform,1.0f, 1.0f);
[UIView animateWithDuration: 0.7
delay: 0.6
options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
animations:^{ StartWalkBtnView.transform = CGAffineTransformScale(transform, 0.0f, 0.0f);
}
completion:^(BOOL finished){
[UIView animateWithDuration:0.0
delay:0.0
options: UIViewAnimationOptionCurveEaseIn
animations:^{
StartWalkBtnView.frame=CGRectMake(92, 270, 120, 121);
}
completion:^(BOOL finished){
StartWalkBtnView.transform=CGAffineTransformScale(transform,0.0f, 0.0f);
[UIView animateWithDuration: 0.7
delay: 0.8
options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
animations:^{ StartWalkBtnView.transform = CGAffineTransformScale(transform, 1.0f, 1.0f);
}
completion:^(BOOL finished){}
];
}];
}
];
}
But After trying to run this Animation I got the following error in the Console.
Jun 17 12:02:49 Kareem.local MyAppName[3157] <Error>: CGAffineTransformInvert: singular matrix.
I googled for this too much, and have tried all the solutions provided (Scale Near to zere Value,...) but nothing worked, Do any one has an idea for solving this. Thanks for help
UPDATE: I found that the problem in the following line:
StartWalkBtnView.frame=CGRectMake(92, 270, 120, 121);
But Actually I don't know how to solve the problem, But when I removed this line It scaled to zero then back from zero normally without any errors
You get this error because the determinant of your scaling matrix is zero. When you attempt to change the transform to scale 1.0, Core Graphics tries to find the inverse matrix of your previous transformation to return the transformation to identity matrix. With determinant 0 this results in a non-inversible matrix, and that's why you get this error. Don't transform scale to 0.0.
Are you sure you checked with near zero values in both scalings you set to 0.0 now?
Edit (Answer):
That is, instead of:
(transform,0.0f, 0.0f);
Try:
(transform,0.01f, 0.01f);
or
(transform,0.001f, 0.001f);
The content of the web page may be the cause of this error, not your iOS app programming.
I found the error occurred in my app only while on Yahoo. Google.com, no problem. Reuters.com, no problem. SeattleTimes.com, no problem. Back to Yahoo.com, problem. Especially while scrolling when the error may appear a few times in a split second.
More detail on my blog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With