I have tried many codes from this website and others too.... But nothing seems to be working for me. Here is my code...
- (IBAction)orientation:(id)sender {
self.currentDeviceOrientation = [[UIDevice currentDevice] orientation];
int cur = self.currentDeviceOrientation;
int port = UIInterfaceOrientationPortrait;
int landl = UIInterfaceOrientationLandscapeLeft;
int landr = UIInterfaceOrientationLandscapeRight;
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
{
NSNumber *value= [NSNumber numberWithInt:UIDeviceOrientationLandscapeLeft];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"orientation"];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
}
}
on the click of a button, I want the screen to change from its current orientation i.e, if the screen is in portrait mode, it should change in to landscape and vice-verse.