Ios 编程方向更改不适用于IPhone 5S
该错误与设备和页面方向有关。 我们的应用程序包括有图形的页面,我们希望,如果页面包含图形,页面应该旋转到左边。同样,如果页面不包含图形,则页面方向应为纵向 为了处理这个问题,我们实现了下面的代码Ios 编程方向更改不适用于IPhone 5S,ios,iphone,objective-c,ios7,Ios,Iphone,Objective C,Ios7,该错误与设备和页面方向有关。 我们的应用程序包括有图形的页面,我们希望,如果页面包含图形,页面应该旋转到左边。同样,如果页面不包含图形,则页面方向应为纵向 为了处理这个问题,我们实现了下面的代码 //static bool isRotationEnabled; //static boundedStatisticsPercentagesNavigationViewController* baseController; // this //static UIInterfaceOrientation
//static bool isRotationEnabled;
//static boundedStatisticsPercentagesNavigationViewController* baseController; // this
//static UIInterfaceOrientation orientationRequest;
+(void)Rotate:(UIInterfaceOrientation)orientation{
if ( orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationLandscapeLeft) {
if (baseController.interfaceOrientation != orientation && (int)[[UIDevice currentDevice] orientation] == (int)orientation) {
isRotationEnabled = YES;
objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), baseController.interfaceOrientation );
orientationRequest = orientation;
[NSTimer scheduledTimerWithTimeInterval:0.1 target:baseController selector:@selector(RotateRequest) userInfo:nil repeats:NO];
}else{
isRotationEnabled = YES;
objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), orientation );
}
}
}
-(void)RotateRequest{
[boundedStatisticsPercentagesNavigationViewController Rotate:orientationRequest];
}
-(BOOL)shouldAutorotate {
if(isRotationEnabled){
isRotationEnabled = NO;
return YES;
}
return NO;
}
上述代码在IPad、IPod、IPhone4、IPhone5、IPhone5S设备的开发环境中运行良好。
我们通过app store将我们的应用下载到我们的设备上。
它适用于除IPhone 5S以外的所有设备。
实际上,这个代码块在我们的应用程序的早期版本中对所有设备都能正常工作
在AppStore中,兼容性部分有一条评论说“此应用程序针对iPhone 5进行了优化”,即使我们在发布版本时没有指定此类内容…
在发布过程中,我们的应用程序可能会发生什么情况?
苹果是否有任何自动应用于应用程序的优化策略
如果您能帮我们找到这个问题的原因,我将不胜感激。苹果的指南不允许这样做,您不能强迫您的用户打开手机。但现在我们可以看到很多应用程序和游戏都是这样做的。 所以有一些方法可以做到这一点。您可以根据需要变换视图
self.view.transform = CGAffineTransformRotate(self.view.transform, -(M_PI / 2.0));
转换程度您可以根据需要决定。我更改了代码
objc_msgSend([ UIDevice currentDevice], @selector(setOrientation:), orientation );
用这个
NSMethodSignature *sig = [[UIDevice currentDevice] methodSignatureForSelector:@selector(setOrientation:)];
NSInvocation* invo = [NSInvocation invocationWithMethodSignature:sig];
[invo setTarget:[UIDevice currentDevice]];
[invo setSelector:@selector(setOrientation:)];
[invo setArgument:&orientation atIndex:2];
[invo invoke];
我的问题解决了