Can anyone explain me what's going on? I use this method
- (BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
{
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
}
to provide landscape orientation for the matchmakerViewController. It works perfectly on iPhone and even on iPad simulator but not on iPad device. When i run the application on iPad matchmakerViewController misteriously appear in the portrait orientation. What's wrong? How do i fix it? Thanks
Change your shouldAutorotateToInterfaceOrientation
like
-(BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
Also check your application plist file, there will be a key like Supported Interface Orientations it's type will be array and will have 4 values . Delete the portrait modes from the plist and save it . It will work. Please check this.
(This is most likely not your problem, but I use the following code and it works fine)
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight)
Additionally, make sure the parent view is set to autorotate true. shouldAutorotateToInterfaceOrientation doesn't work
Here is the elegant solution through Categories, extend the GKMatchMakerViewController, the same solution will work on any other game center view such as leader board views and achievement views:
.h file
#import <Foundation/Foundation.h>
#import "GameKit/GameKit.h"
@interface GKMatchmakerViewController(LandscapeOnly)
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;
@end
.m file
#import "GKMatchmakerViewController-Landscape.h"
@implementation GKMatchmakerViewController(LandscapeOnly)
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
@end
Let me know if it works!!
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
also check parent controller maybe some controller return YES
or try
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if (interfaceOrientation==UIInterfaceOrientationPortrait)
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
else
return NO;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.