Ios GameCenter横向定位不';我不能在iPad上工作

Ios GameCenter横向定位不';我不能在iPad上工作,ios,ipad,game-center,Ios,Ipad,Game Center,谁能解释一下发生了什么事?我用这个方法 - (BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation { return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) ); } 为matchmakerViewController提供横向方向。它可以在iPhone甚至iPad模拟器上完美运

谁能解释一下发生了什么事?我用这个方法

- (BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
 {     
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
 }
为matchmakerViewController提供横向方向。它可以在iPhone甚至iPad模拟器上完美运行,但不能在iPad设备上运行。当我在iPad上运行应用程序时,matchmakerViewController错误地出现在纵向。发生了什么?我怎么修理它?谢谢

(这很可能不是您的问题,但我使用以下代码,它工作正常)


此外,请确保父视图设置为autorotate true

更改您的
shouldAutorotateToInterfaceOrientation

-(BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
 {     
     return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
 }
同时检查应用程序plist文件,将有一个,如支持的界面方向它的类型将是数组,并且将有4个值从plist中删除纵向模式并保存它
它会起作用的。请检查此项。

这是通过分类的优雅解决方案,扩展GKMatchMakerViewController,相同的解决方案将适用于任何其他游戏中心视图,如排行榜视图和成就视图:

.h文件

#import <Foundation/Foundation.h>
#import "GameKit/GameKit.h"

@interface GKMatchmakerViewController(LandscapeOnly)



-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;

@end

让我知道它是否有效

@AndreyChernukha:您是否检查了父视图控制器的shouldAutorotateToInterfaceOrientation:方法?它与return(interfaceOrientation==UIInterfaceOrientationAndscapeLeft | | interfaceOrientation==UIInterfaceOrientationAndscapeRight)相同吗?是的。不一样。如果我让它返回(interfaceOrientation==UIInterfaceOrientationAndscapeLeft | | interfaceOrientation==UIInterfaceOrientationAndscapeRight);它开始以纵向显示mode@AndreyChernukha:您的完整应用程序是在横向模式下工作还是仅此视图设置为横向?所有应用程序都是横向的请从shouldAutorotateToInterfaceOrientation方法返回“否”。检查视图是否旋转。还添加[[UIDevice currentDevice]BegingeratingDeviceOrientationNotifications];在应用程序中,委托ApplicationIDFinishLoading方法。检查并更新我将帮助您。或尝试将(interfaceOrientation==UIInterfaceOrientation==UIInterfaceOrientationAndscapeLeft)交换到(interfaceOrientation==UIDeviceOrientationGraphic)
- (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;
}
#import "GKMatchmakerViewController-Landscape.h"

@implementation GKMatchmakerViewController(LandscapeOnly)


-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

   return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);


}

@end
- (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;
}