0

Possible Duplicate:
How to force a screen orientation in specific view controllers?

hello

I want to set the orientation in one particular view so how can i do that. andbody have example for that. i used the

-(void)onUIDeviceOrientationDidChangeNotification:(NSNotification*)notification{
    UIViewController *tvc = self.navigationController.topViewController;
    UIDeviceOrientation orientation = [[ UIDevice currentDevice ] orientation ];
    tabBarController.view.hidden = YES;
    // only switch if we need to (seem to get multiple notifications on device)
    if( orientation != [[ UIApplication sharedApplication ] statusBarOrientation ] ){
        if( [ tvc shouldAutorotateToInterfaceOrientation: orientation ] ){
            [ self rotateInterfaceToOrientation: orientation ];
        }
    }
}

but its done is whole application and i want to done only in one screen so please reply thank you

Community
  • 1
  • 1
Naresh
  • 181
  • 1
  • 1
  • 11
  • do u want to apply single orientation for your app??? – ajay May 11 '11 at 07:37
  • Duplicate of http://stackoverflow.com/questions/314382/how-to-force-a-screen-orientation-in-specific-view-controllers, http://stackoverflow.com/questions/3686303/uiviewcontroller-rotating-problem and http://stackoverflow.com/questions/5297103/how-to-set-screen-orientation-like-landscape-view-programmaticaly-in-iphone – Chetan Bhalara May 11 '11 at 06:57

3 Answers3

0
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    // Over ride this method in your required view controller to display only in the necessary orientation
}
visakh7
  • 26,380
  • 8
  • 55
  • 69
0

Add this method in your class

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    // Over ride this method in your required view controller to display only in the necessary orientation
     return YES;
}
PgmFreek
  • 6,374
  • 3
  • 36
  • 47
0

on a particula view controller put

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

this is for potrait for other u can do like wise

Kshitiz Ghimire
  • 1,716
  • 3
  • 18
  • 37