我正在使用旧的X-Code版本创建的iOS应用程序,因此它在MainWindow.xib中有窗口.
最近,当我在iOS8 Beta版本中运行这个项目时,我遇到了一个问题:窗口没有横向旋转.所以我在MainWindow.xib中添加了另一个窗口.我做了条件检查操作系统版本,对于旧的iOS版本我使用以前创建的窗口,但对于iOS8我使用新添加的窗口横向方向.我已经解决了这个问题.除相机外,整个应用程序都正常工作.
以下是截屏.
在LandscapeMode中(它正常工作):
在PortraitMode中(一旦相机被加载,我已经旋转它,其他控件正在旋转,但相机过度旋转不正常):
一旦相机以横向模式加载,我已旋转设备,控件正在旋转,但相机屏幕没有旋转,它仍处于纵向模式.
这可能是由于Appdelegate中的窗口.
对此有何解决方案?
提前致谢.
最佳答案 我有相同的问题.
我试着使用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
它似乎工作
但来源并不美丽……