Skip to content

Commit

Permalink
Fix QR code scanning rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
drewconner committed Dec 5, 2013
1 parent de5d1dc commit f21dad3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ChimpKit3/Helper Objects/CKScanViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ - (void)viewDidLoad {
}
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:duration] forKey:kCATransactionAnimationDuration];

if (self.previewLayer) {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
self.previewLayer.affineTransform = CGAffineTransformMakeRotation(0);
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
self.previewLayer.affineTransform = CGAffineTransformMakeRotation(M_PI/2);
} else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
self.previewLayer.affineTransform = CGAffineTransformMakeRotation(M_PI);
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
self.previewLayer.affineTransform = CGAffineTransformMakeRotation(-M_PI/2);
}

self.previewLayer.frame = self.view.bounds;
}

[CATransaction commit];
}

- (void)dealloc {
[self.previewLayer removeFromSuperlayer];
self.previewLayer = nil;
Expand Down
4 changes: 4 additions & 0 deletions Sample App/ChimpKitSampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
3A9A6AAC169B167400994BE6 /* ChimpKitRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A9A6AAB169B167400994BE6 /* ChimpKitRequest.m */; };
3A9A6AB2169B262E00994BE6 /* CKAuthViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A9A6AAF169B262E00994BE6 /* CKAuthViewController.m */; };
3A9A6AB3169B262E00994BE6 /* CKSubscribeAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A9A6AB1169B262E00994BE6 /* CKSubscribeAlertView.m */; };
3AE6C5141850F9910031658A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AE6C5131850F9910031658A /* QuartzCore.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -58,13 +59,15 @@
3A9A6AAF169B262E00994BE6 /* CKAuthViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CKAuthViewController.m; sourceTree = "<group>"; };
3A9A6AB0169B262E00994BE6 /* CKSubscribeAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CKSubscribeAlertView.h; sourceTree = "<group>"; };
3A9A6AB1169B262E00994BE6 /* CKSubscribeAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CKSubscribeAlertView.m; sourceTree = "<group>"; };
3AE6C5131850F9910031658A /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
3A9A6A66169B135D00994BE6 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3AE6C5141850F9910031658A /* QuartzCore.framework in Frameworks */,
3A3AFC16181FFC6300A0FD55 /* AVFoundation.framework in Frameworks */,
3A9A6A6E169B135D00994BE6 /* UIKit.framework in Frameworks */,
3A9A6A70169B135D00994BE6 /* Foundation.framework in Frameworks */,
Expand Down Expand Up @@ -96,6 +99,7 @@
3A9A6A6C169B135D00994BE6 /* Frameworks */ = {
isa = PBXGroup;
children = (
3AE6C5131850F9910031658A /* QuartzCore.framework */,
3A3AFC15181FFC6300A0FD55 /* AVFoundation.framework */,
3A9A6A6D169B135D00994BE6 /* UIKit.framework */,
3A9A6A6F169B135D00994BE6 /* Foundation.framework */,
Expand Down

0 comments on commit f21dad3

Please sign in to comment.