
我已经为视图旋转创建了类别,并在控制器视图和窗口上添加了视图(用于显示自定义指示符)。我的代码在xCode 5.X和xCode6-beta6中运行良好,可以达到7.X。但IOS 8测试版并不合适。它似乎不像旧版的ios 8测试版那样适用于windows轮转。
你能建议我..。提前谢谢。
我的代码看起来像
- (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];
}
}发布于 2014-09-06 10:00:59
我试过很多修复方法..。它和补丁一起工作,比如
{
[self.window setBounds:temp];
[menu.view setFrame:CGRectMake(0, self.window.frame.size.height-50, self.window.frame.size.width, 50)];
[menu.view removeFromSuperview];
[self.window addSubview:menu.view];
[self.window makeKeyAndVisible];
}对于所有类型的设备模式,对于CGAffineTransformMakeRotation,对于ios 8,重新设定角度到0度。
这不是一个正确的解决方案,我知道,但我没有任何替代的方式,所以等待一个好的答案。
发布于 2014-09-29 23:02:30
在我的例子中,简单地将所有方向的旋转角设置为0就解决了这个问题。在iOS 8之前,UIWindow坐标一直是面向肖像的,所以你必须自己处理旋转。这在iOS 8中不再是必要的。至于为什么要将UIViews添加到UIWindow中,我这样做是因为我想在其他所有东西上显示警报,而不管当前的视图层次结构如何。
https://stackoverflow.com/questions/25684892
复制相似问题