Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-13-2011, 05:35 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 11
coding is on a distinguished road
Default rotating layer 90° when orientation changes 180° confuses me

Hello dev colleagues,

I seem to be a little braindead at the moment. My problem is I don't understand a specific orientation change / view rotation situation.

Based on a view that has a layer (AVCaptureVideoPreviewLayer) to preview video from camera on the iPhone's screen, I want to support landscape orientation in addition to portrait orientation (standard is portrait though). So when I rotate the device from portrait to landscape, I modify the view's frame and perform a CATransform3DMakeRotation (90 degrees = 90/180*M_PI) on the preview layer. This is working well, the following procedure confuses me though:

Changing the orientation from landscape-left to landscape-right is a rotation by 180 degree, though the view controllers message willRotateToInferfaceOrientation gets called once where i rotate the preview layer by 90 degrees. In fact, the preview layer gets rotated by 180 degrees and adapts properly to the new orientation. But I only rotate by 90 degrees in code??

Anyone who can give me a hint on this?? Thanks in advance
coding is offline   Reply With Quote
Old 09-13-2011, 09:08 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Can you post your rotation code?
smithdale87 is offline   Reply With Quote
Old 09-13-2011, 09:41 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 11
coding is on a distinguished road
Default

thanks for your interest. I definitely know that when rotating from landscape-left to landscape-right the message below (in the code) gets called once containing the desired orientation.

Code:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
CGFloat rotationAngle = 0.0;
        if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { // home button is on the left side
            rotationAngle = 90.0/180.0*M_PI; // rotate left
        } else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { // home button is on the right side
            rotationAngle = -90.0/180.0*M_PI; // rotate right
        }
        CATransform3D transform = CATransform3DMakeRotation(rotationAngle, 0, 0, 1.0);
        [layer setTransform:transform];
}
coding is offline   Reply With Quote
Reply

Bookmarks

Tags
camera, capture, orientation, preview, rotate

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 401
9 members and 392 guests
7twenty7, Eclectic, eski, fiftysixty, JackReidy, teebee74, tim0504, UMAD, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:06 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0