-2

how can i lock landscape in ios., i was tried many method but not worked, Can any one share latest code for lock landscape.

-(void) portraitLock {
    BSEAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
    appDelegate.screenIsPortraitOnly = true;
}

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}

+(BOOL)shouldAutorotate
{
    return NO;
}

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    return (interfaceOrientation == UIInterfaceOrientationPortrait);

}
Bhavesh Nayi
  • 3,626
  • 1
  • 27
  • 42
PothiraJ
  • 65
  • 14

2 Answers2

0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

As of IOS6 shouldAutorotateToInterfaceOrientation was depreciated in place of willRotateToInterfaceOrientation or didRotateFromInterfaceOrientation

You should also change the views orientation to Landscape in the Attributes Inspector.

If your entire app is to be displayed in Landscape you can also add UISupportedInterfaceOptions to your apps info.plist and specify Landscape.

davidcondrey
  • 34,416
  • 17
  • 114
  • 136
0

Check above Image

Check Image

check only Portrait mode.,,,,

Bhavesh Nayi
  • 3,626
  • 1
  • 27
  • 42