UIView rotates while scaling using CGAffineTransformMakeScale
Im using CGAffineTransformMakeScale to scale a UIView from 0.1 to 1.0.
The problem is that the view is also rotating while the scaling is being animated. So it ends with a scale of 1.0 AND 90º of rotation.
[self presentModalViewController:slideTwoViewController animated: NO]; [slideTwoViewController.view setTransform:CGAffineTransformMakeScale(0.1,0.1)]; [UIView beginAnimations: nil context: nil]; [UIView setAnimationDuration:2.0]; [slideTwoViewController.view setTransform:CGAffineTransformMakeScale(1.0,1.0)]; [UIView commitAnimations];
The initial application orientation is landscape left. So when the animation ends the UIView looks like in portrait.
Is this supposed to happen? am I missing something?
- Load only five annotations to MKMapVIew
- iOS: How do I know if a property is KVO-compliant?
- Is there any way to switch on/off bluetooth in iPhone programatically?
- Which is the best method to display thumbnail images on UIScrollview (downloaded from server)
- Getting image name of iphone photo library
- Convert a string into an int
2 Solutions Collect From Internet About “UIView rotates while scaling using CGAffineTransformMakeScale”
My bet, is the view already have a transform set and you are overwriting it with the new transform and it is animating the difference.
Try using the following function instead:
CGAffineTransformScale(<#CGAffineTransform t#>, <#CGFloat sx#>, <#CGFloat sy#>)
With this function, you pass the original transform
slideTwoViewController.view.transform and your scale factor.
slideTwoViewController.view.transform = CGAffineTransformScale(slideTwoViewController.view.transform, 0.1, 0.1);
Despite of scaling rootview try to add subview which become your new pseudo rootview (with all the rest subviews connected underneath) and then scale pseudo rootview. This way you are avoiding any transform collisions made by system on the real rootview (e.g. autorotating) and then you can use CGAffineTransformMakeScale freely.
- iOS automatic @synthesize without creating an ivar
- How to get Size of UIImage in Bytes in iOS 4.0+?
- Swift enum raw value: not working with CGFloat = -1.0
- Redirecting debug output from XCode 4 console to a log file
- Swift 3- Convert characters side from right to left or left to right
- Naming convention (Singular or plural name class)
- Correct loadView implementation
- UITableViewSection Row Indices
- Objective-C: When to call self.myObject vs just calling myObject
- iPhone – Adjust UILabel width according to the text
- PhoneGap Launch Image iOS Apple Store Submission
- How to sort the table view from A-z?
- How do I connect an AudioFilePlayer AudioUnit to a 3DMixer?
- Linker Command Failed with Exit Code 1 (use -v to see invocation) with Google Ads
- Can I use AVAudioEngine to read from a file, process with an audio unit and write to a file, faster than real-time?