I'm integrating Everyplay with my Cocos2d Game.My game only support Landscape orientation.
Everything goes well on iPad.
But When i test on iPhone(iOS6),it throws exception as following when I call "[[Everyplay sharedInstance] showEveryplay]":
reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
I know orientation mechanism changed in iOS6.So i add this method:
-(BOOL)shouldAutorotate{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
Then "[[Everyplay sharedInstance] showEveryplay]" works without exception, but my game also support Portrait orientation that I do not want to.
How can I do if I only want to support Landscape in My Game, but let "[[Everyplay sharedInstance] showEveryplay]" works without exception?
You have two options how to fix the problem.
Option 1:
Add UISupportedInterfaceOrientations array into your game's info.plist with items UIInterfaceOrientationPortrait, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight and UIInterfaceOrientationPortraitUpsideDown. You can easily do this from xCode by checking all Supported Interface Orientations from your project summary page or by editing the info.plist file manually.
Option 2:
Add the following method to your application's AppDelegate.m file:
// IOS 6
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAll;
}
In both cases you must also make sure that you have added the landscape only orientation handling code to your game's main UIViewController.
// IOS 5
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
// IOS 6
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
On iPhone Everyplay webview is always on portrait mode, but on iPad the webview supports both. Recording supports both modes as does the video player. We will likely in near future update the landscape mode for iPhone resolution too, but it will require some redesign before this task is complete.
Related
I want to display the video in landscape mode only when video is playing in fullscreen using MPMoviePlayerController in ios6. My application supports only portrait mode.
Can anybody please suggest me, how can i do this?
Thanks.
I got the answer from below link
iOS 6 MPMoviePlayerViewController and presentMoviePlayerViewControllerAnimated Rotation
Make changes in application delegate file as fllows and its working:
Only change the UIview name as MPSwipableView in ios6
- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if ([[self.window.subviews.lastObject class].description isEqualToString:#"MPSwipableView"]) {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else {
return UIInterfaceOrientationMaskPortrait;
}
}
In your viewController, implement this method,
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape
}
I am searching the whole net for days, but can't find an answer.
The problem is: I can't force my app to present ALL UIViewControllers just in portrait mode, except one UIViewController, which should be able to work in every of the 4 modes.
Those are my options:
iOS 6
UINavigationController
UITabBarController
Storyboard
All modes are enabled in the project (also in Info.plist)
I already tried
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
but it does not even seem to work..
Any idea?
Found the answer:
Subclass UINavigationController (https://stackoverflow.com/a/12999017/1011125) OR UITabBarController if used.
Set up the orientations (https://stackoverflow.com/a/12539784/1011125).
That's it :).
So, i'm fix interface Iphone is portrait and i wanna show landscapte when i playing video(using MPMoviePlayerController), i have read in ios6 sdk,ShouldAutorotateToInterfaceOrientation is deprecated. How to rotate only this player view? I can only rotate whole app, but don't want to do this.
i tryed with
(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
in this link or link but video still doesn't change.. Can you help me
First of all, in your app settings, do you allow any other orientation besides portrait?
Second, is your view controller embedded in an UINavigationController/UITabBarController/UISplitViewController?
The code you posted is supposed to work as a category or by subclassing an UINavigationController. If your container is not a UINavigationController, it won't work.(at least not for UITabBarController).
Can you also post the code where you enable to rotation for your view controller?
Also, it could be helpful to also show the whole code for your category/subclass.
I have to write an universal app, the iPhone part has only to be presented in Portrait so it would be the preferred orientation and it doesn't have to support other orientations, BUT I encountered the problem that adding a MPMoviePlayerController inside a modally presented controller it's ability have to rotate in Landscape.
For this if I block only in portrait the supported interface orientations in the app settings and in that controller I do:
- (BOOL) shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeRight;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
the result is a 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!' crash.
Otherwise if I have to set supported orientations Portrait and Landscape but everywhere block the preferred orientation and set shouldrotate to NO in every controller should work I suppose but it would be really a bad thing in my opinion.
How you will do with this kind of new interface orientation mechanism?
Thanks
I've been using Xcode 4.4 for my project for iOS and I wanted one of my screens to be permanently landscape so I used
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
and it worked just fine and since I updated to Xcode 4.5 and iOS 6.0 it didn't work at all so I found out that I have to use the new functions and now I have:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)shouldAutorotate {
return YES;
}
so now my screen is landscape but the status bar remains in its place like the screen is still in portrait mode.
I don't know how to fix it.
Thank you.
I implemented this into the viewWillAppear function and it worked in iOS6:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];