views:

889

answers:

1

Hi!

I need to implement behavior of my UIViewController subclass like in standart iPod.app: when device rotated from portrait to landscape, content of UIViewController stay's still and new view add's above it.

The problem is that, when set

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

the content is rotating

but when set

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return NO;
}

function

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    NSLog(@"did rotate form interface orientation %d",fromInterfaceOrientation);
}

is newer called

So, do you know how to handle device rotation inside UIViewController without rotating it content?

+3  A: 

Actually, you do NOT want your viewController to respond to interface orientation rotation.

Instead, it is easier just to observe UIAccelerometer notifications. Then do a full swap of the view.

You can see the code to do this here on SO:

http://stackoverflow.com/questions/730799/rotating-the-iphone-and-instantiating-a-new-uiviewcontroller/893785#893785

and

http://stackoverflow.com/questions/930075/uidevice-orientation/930336#930336

Corey Floyd