ios 8的旋转问题用于添加到窗口的视图 [英] Rotation issue with ios 8 for view which are added to windows

查看:155
本文介绍了ios 8的旋转问题用于添加到窗口的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了视图旋转类别,并在控制器视图中添加了视图以及在窗口上(用于显示自定义指标)。
使用xCode 5.X以及xCode6-beta6,我的代码可以正常工作到7.X.但是IOS 8 beta不合适。
它看起来像Windows旋转不能与ios 8 beta一样使用,比较旧的ios。

I have created category for view rotation, And added views on controllers view as well as on window(for showing custom indicator). My code is working fine up to 7.X with xCode 5.X as well as xCode6-beta6. But is not proper with IOS 8 beta. Its seems like windows rotation is not working with ios 8 beta same like older ios.

你能建议我....
谢谢提前很多。

Can you please suggest me.... Thanks a lot in advance.

我的代码看起来像

- (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];
 }
}


推荐答案

我已经尝试了很多修复......并且它使用补丁类似

I have tried a lot of fixes... and its working with patch like

{
[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的角度重置为0度。对于ios 8。

and reseting angle to 0 degree for CGAffineTransformMakeRotation for all kind of device mode., for ios 8.

我知道这不是一个合适的解决方案,但我没有任何其他方式等待一个好的答案。

This is not a proper solution i know, but I don't have any alternate way so waiting for a good answer.

这篇关于ios 8的旋转问题用于添加到窗口的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆