PDA

View Full Version : rotation




chhoda
Dec 20, 2008, 10:45 PM
I have a viewcontroller class where I am doing

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
return YES;
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation // Notification of rotation ending.
{
NSLog(@"Orientation: %@", fromInterfaceOrientation);
}


but the log is never printed, does rotation work properly in simulator ? or i need to test that on device ?

ch



ghayenga
Dec 21, 2008, 12:18 PM
I have a viewcontroller class where I am doing

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
return YES;
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation // Notification of rotation ending.
{
NSLog(@"Orientation: %@", fromInterfaceOrientation);
}


but the log is never printed, does rotation work properly in simulator ? or i need to test that on device ?

ch

You should be getting a crash with that code since a UIInterfaceOrientation is actually an integer. If I change the logging code to:

NSLog(@"Orientation: %d", fromInterfaceOrientation);

it works fine in the simulator.

chhoda
Dec 22, 2008, 01:42 AM
I wish I got a crash even ! i put a breakpoint in both the functions and try debug, breakpoint is never hit !

bigsprocket
Dec 22, 2008, 10:02 PM
Then your viewcontroller isn't being used. Is there a reference to your viewcontroller in the main NIB file, and that's how you expect it to be instantiated? Can you post the rest of your code?

chhoda
Jan 2, 2009, 03:43 AM
Its quite a bit of code to post here. WOuld you mind which portions of the code you wanna have a look ?

> Is there a reference to your viewcontroller in the main NIB file, and that's how you expect it to be instantiated?

by the way, how would I verify this, if I am not sure ?

regards
CH

chhoda
Jan 2, 2009, 03:49 AM
is there a simulator setting which blocks/releases these rotation events to viewcontroller ? I am getting this feeling because I see in my simulator, the native aplication like photos, safari, addressbook also do not respond to landscape potrait rotation

rgds
ch

ghayenga
Jan 2, 2009, 09:22 AM
is there a simulator setting which blocks/releases these rotation events to viewcontroller ? I am getting this feeling because I see in my simulator, the native aplication like photos, safari, addressbook also do not respond to landscape potrait rotation

rgds
ch

No, there's not.

However your viewController may return YES for shouldAutoRotate but if something else further up the view controller stack *doesn't* then your view won't rotate anyway.