views:

39

answers:

1

Hello everybody. I have a Main View that contatins uitableview, and i am pushing another view when the user taps on a row. I want only the child views to rotate and have written code for that. But the problem is once i push the view, it also enables the orientation on the Main View. when i rotate the main view to the left, the statusbar also changes to the left. i have not applied any orientation on the Main View. i have done the following on the MainView but code still the status bar doesnt change.

 -(void) viewDidLoad
{
     [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
     [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(receivedRotate:) name: UIDeviceOrientationDidChangeNotification object: nil];
 }

-(void) receivedRotate: (NSNotification*) notification
 {
    UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];

    if(interfaceOrientation != UIDeviceOrientationUnknown)
    {
        if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft)
        {
           [self shouldAutorotateToInterfaceOrientation:interfaceOrientation];
        }
    }

}

can somebody plz help me????its kinda urgent... How can i disable interfaceOrientation in the Main view

A: 

in your main view controller, override this delegate:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation; // Override to allow rotation. Default returns YES only for UIDeviceOrientationPortrait
{
    if((toInterfaceOrientation == UIInterfaceOrientationLandscapeRight))
        return YES;
    return NO;
}

Now your main view controller will always be in landscape mode. And remove all your code which you mentioned above. you should not call the "shouldAutorotateToInterfaceOrientation:" method.

Manjunath
the shouldAutorotate function is not getting called automatically, so i have added a notification and called the function when the rotation notification is received. And i dnt want rotation in all the views, only in certain views. but it seems that my main view, where i have not applied rotation is affected by its child views. When i rotate the main view, everything stays in portrait except for statusbar. So any help on that????
Jayshree