I need to change the orientation of the application while the application is running. My process is that if I turn on the switch, the application must change its orientation (ie) (i) if the application works in landscape orientation, and then if I return "ON" to the switch button, then the device orientation should automatically change in portrait mode. (ii) if the application is in Portrait mode, if I turn off the switch, then the orientation of the device should automatically change to landscape mode ... I tried something, but it is not hushed up for me .. can anyone give some solution? for this..
- (IBAction)PortraitSwitchPressed:(UISwitch *)sender
{
if (sender.isOn)
{
UIInterfaceOrientationMaskPortrait;
[[UIDevice currentDevice]setOrientation:UIInterfaceOrientationPortrait];
[self.PortraitSwitch setOn:YES animated:YES];
}
else
{
UIInterfaceOrientationMaskLandscape;
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationMaskLandscape];
[self.PortraitSwitch setOn:NO animated:YES];
}}