我正在开发一个使用旧的X代码版本创建的iOS应用程序,所以它在MainWindow.xib中有一个窗口。最近,当我在iOS8 Beta版本中运行这个项目时,我遇到了一个问题:窗口不是在景观方向旋转的。因此,我在MainWindow.xib中添加了另一个窗口。我设定了if条件来检查OS版本,对于较早的iOS版本,我使用以前创建的窗口,而对于iOS8,我使用新添加的窗口进行横向定位。我已经解决了这个问题。除摄像机外,整个应用程序都正常工作。
下面是屏幕截图。
In LandscapeMode(它正在正常工作):

In PortraitMode(一旦装载了相机,我就旋转了它,这里的其他控件都是正确旋转的,但相机过度旋转不合适):

一旦相机加载到景观模式,我已经旋转设备,控制是正确的旋转,但相机屏幕不是旋转,它仍然在纵向模式。这可能是由于应用程序中的窗口。
有什么解决办法吗?
提前谢谢。
发布于 2014-09-19 10:35:31
我也有同样的问题。
我被试着使用cameraViewTransform。
下面
#import "MyUIImagePickerController.h"
@implementation MyUIImagePickerController
bool rotateFlg = false;
UIInterfaceOrientation startupOrientation;
-(id)init{
startupOrientation = [[UIApplication sharedApplication] statusBarOrientation];
return [super init];
}
-(NSUInteger)supportedInterfaceOrientations {
// iOS 8
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) {
float lotate[4];
if (startupOrientation == UIInterfaceOrientationLandscapeRight || startupOrientation == UIInterfaceOrientationLandscapeLeft) {
lotate[0] = 90.0f;
lotate[1] = -90.0f;
lotate[2] = 180.0f;
lotate[3] = 0.0f;
} else {
lotate[0] = 0.0f;
lotate[1] = 180.0f;
lotate[2] = 90.0f;
lotate[3] = -90.0f;
}
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation ==UIInterfaceOrientationPortrait ){
CGAffineTransform __rotation = CGAffineTransformMakeRotation(lotate[0] * M_PI / 180.0f);
self.cameraViewTransform = __rotation;
rotateFlg = true;
}
else if(orientation == UIInterfaceOrientationPortraitUpsideDown){
CGAffineTransform __rotation = CGAffineTransformMakeRotation(lotate[1] * M_PI / 180.0f);
self.cameraViewTransform = __rotation;
rotateFlg = true;
} else if(orientation == UIInterfaceOrientationLandscapeLeft){
if (rotateFlg) {
CGAffineTransform __rotation = CGAffineTransformMakeRotation(lotate[2] * M_PI / 180.0f);
self.cameraViewTransform = __rotation;
rotateFlg = false;
}
}else if(orientation == UIInterfaceOrientationLandscapeRight){
if (rotateFlg) {
CGAffineTransform __rotation = CGAffineTransformMakeRotation(lotate[3] * M_PI / 180.0f);
self.cameraViewTransform = __rotation;
rotateFlg = false;
}
}
}
return UIInterfaceOrientationMaskAll;
}
@end它看起来很管用
但源头并不美丽..。
发布于 2014-11-14 16:11:16
发布了我认为是解决方案的信息,在;https://stackoverflow.com/a/26934067/782533上发布
看起来是同一个问题吗?不确定我是否应该链接或复制/粘贴,所以这是无论如何;
我也有同样的问题,在回到基础上,并创建了一个新的项目,实际上是有效的。我追踪到了;
-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
// Had forgot to call the following..
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}希望能帮上忙。
发布于 2014-09-16 16:53:10
根据Apple论坛上的这篇文章的说法,iOS8 8/XCode6 6在使用XIB时存在一些问题,但在使用故事板时却没有问题。
https://stackoverflow.com/questions/25139246
复制相似问题