views:

511

answers:

1

Apple demonstrated Photo's for the iPad. In their demo, they said you can Flip the iPad and it flips the image.

How is this result achieved?

I've been reading about UIInterfaceOrientation all day and I'm lost

Any help would be appreciated.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
//  NSLog(@"orientation: %@", [orientation )
if(orientation==UIInterfaceOrientationPortrait ||orientation==UIInterfaceOrientationPortraitUpsideDown) {
    //Code
    return NO;
}  
if (orientation==UIInterfaceOrientationLandscapeRight ||orientation==UIInterfaceOrientationLandscapeLeft ) {
    //Code
    return YES;
}
return NO;
}
A: 

You implement in your UIViewController subclass:

- (BOOL)shouldAutorotateToDeviceOrientation:... {
    Return YES;
}

And most of the time the UIKit manages it all for you.

Paul Lynch
thanks but how do you know when its flipped?- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation]; // NSLog(@"orientation: %@", [orientation ) if(orientation==UIInterfaceOrientationPortrait ||orientation==UIInterfaceOrientationPortraitUpsideDown) { //Code return NO; } if (orientation==UIInterfaceOrientationLandscapeRight ||orientation==UIInterfaceOrientationLandscapeLeft ) { //Code return YES; } return NO;}
Cocoa Dev
I tested it and it doesn't appear to do any flipping. I'm not even sure when I flip.
Cocoa Dev
(most of the time) you don't care if the view is flipped or not, the device handles rotation for you. If your controllers are within tab/nave controllers, you need to make sure that ALL view controllers return true from this method.
Paul Lynch
Paul. If you have an iPad, please download Billboardz: ROAD RAGEYou'll pick a sign then flip it (so the screen is NOT facing you). The words are inverted so you can read them in a mirror. I want to perform something like that for my app. Its possible but if you have some sample code to demo that, I'd really appreciate it!
Cocoa Dev
Aha! That's a totally different flip, not really related to device orientation.
Paul Lynch