ios 8的旋转问题用于添加到窗口的视图

 姝susuju_110 发布于 2022-12-23 12:50

在此输入图像描述我已经为视图旋转创建了类别,并在控制器视图和窗口上添加了视图(用于显示自定义指示器).使用xCode 5.X以及xCode6-beta6,我的代码可以正常工作到7.X. 但是IOS 8 beta不合适.它看起来像Windows旋转不适用于ios 8 beta,就像老款ios一样.

你能不能建议我......非常感谢你提前.

我的代码看起来像

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

Kanjariya-IO.. 7

我已经尝试了很多修复程序......它和补丁一样工作

{
[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.

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

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有