Reputation: 198
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.
Upvotes: -1
Views: 432
Reputation: 675
there is One way, use 2 UIViewController
objects... one with portrait and other landscape Orientation. this will work Smooth. except that no way
Upvotes: 0
Reputation: 4174
There is no officially supported way to do what you are asking for. There are several workarounds posted under this question but most of them are kludges and will probably break in future versions of iOS (if they haven't already), or will get your app rejected on app store submission. Apple doesn't want you setting the orientation manually because they feel it will confuse users and it breaks their UI design guidelines.
See Apple's Human Interface Guidelines document for reference.
Upvotes: 0