我创建了视图旋转的类别,并在控制器视图以及窗口(用于显示自定义指标)上添加了视图。 我的代码在xCode 5.X以及xCode6-beta6中正常工作到7.X。但是IOS 8测试版不适合。 它似乎像Windows旋转不工作与ios 8测试版相同像老ios。ios 8添加到窗口的视图的旋转问题
您能否请我建议.... 非常感谢。
我的代码看起来像
- (void)application:(UIApplication *)application willChangeStatusBarOrientation:(UIInterfaceOrientation)newStatusBarOrientation duration:(NSTimeInterval)duration {
if(!self.isIpad)
{
[menu.view rotateViewToOrientation:newStatusBarOrientation animated:YES];
if(newStatusBarOrientation==UIInterfaceOrientationPortrait || newStatusBarOrientation==UIInterfaceOrientationPortraitUpsideDown)
{
if (IS_IPHONE_5) {
menu.view.frame= CGRectMake(0, 518, 320, 50);
} else {
menu.view.frame= CGRectMake(0, 430, 320, 50);
}
} else if(newStatusBarOrientation==UIInterfaceOrientationLandscapeLeft) {
if (IS_IPHONE_5) {
menu.view.frame= CGRectMake(270,0,50,568);
} else {
menu.view.frame= CGRectMake(270,0,50,480);
}
} else {
if (IS_IPHONE_5) {
menu.view.frame= CGRectMake(0,0,50,568);
} else {
menu.view.frame= CGRectMake(0,0,50,480);
}
}
[menu reloadMenu];
}
}
//Method of Menu Class for orientation change setup
- (void)rotateViewToOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated {
CGPoint center = self.center;
CGRect bounds = self.bounds;
CGAffineTransform transform = CGAffineTransformIdentity;
int intOri=orientation;
switch (intOri) {
case UIInterfaceOrientationPortraitUpsideDown:
transform = CGAffineTransformMakeRotation(M_PI);
break;
case UIInterfaceOrientationLandscapeLeft:
transform = CGAffineTransformMakeRotation(-M_PI_2);
break;
case UIInterfaceOrientationLandscapeRight:
transform = CGAffineTransformMakeRotation(M_PI_2);
break;
case UIInterfaceOrientationPortrait:
transform = CGAffineTransformMakeRotation(0);
break;
}
if (animated) {
[UIView beginAnimations:nil context:nil];
}
self.transform = transform;
bounds = CGRectApplyAffineTransform(bounds, transform);
self.bounds = CGRectMake(0, 0, bounds.size.width, bounds.size.height);
self.center = center;
if (animated) {
[UIView commitAnimations];
}
}
粘贴一些代码,并告诉你如何获得的问题,有什么功能不调用,否则任何事情? – Jageen 2014-09-05 11:42:13
一般来说,大多数开发人员不知道如何构建适当的视图层次结构,这可能是问题的根源 - 您能否发布一些关于如何构建您的代码的代码? – holex 2014-09-05 11:54:31
@Jageen我已经添加了我的代码,您能否以任何方式给我建议,我应该如何使我的应用程序兼容ios 8。 – 2014-09-05 12:21:26