I'm using an iPAD 2 with OS version 9.3. My application tries to change the device orientation but its not changing. How to change device orientation in iOS 9.0. My question is when app is started it should be Portrait and should not autorotate. After button click it should change orientation to LandscapeRight.
And for your info all orientations are checked in project .plist file
My code in my view controller:
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:YES];
[[UIDevice currentDevice] setValue:
[NSNumber numberWithInteger: UIInterfaceOrientationPortrait]
forKey:@"orientation"];
}
- (BOOL)shouldAutorotate {
return NO;
}
and on a button click
-(IBAction)playMyVideo:(MPMediaItem*)item{
[[UIDevice currentDevice] setValue:
[NSNumber numberWithInteger: UIInterfaceOrientationLandscapeRight]
forKey:@"orientation"];
}
What is the problem with the code? If there isn't any problem what is the solution for this?
Note: In iPhone there is an app called Videos he is handling the rotation on button clicks. Its a system app. How is he doing that.