首页 文章

iPad从纵向旋转到横向

提问于
浏览
1

我的观点最初是横向模式 . 当一个按钮被粘贴时,一个视图以纵向模式打开,一切都可以找到 . 问题是当我从该视图返回到根视图时,视图将无法正确旋转 . 这是我用来将视图从纵向旋转到横向的代码,

-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];

//rotate the page to lansscape
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(-90*0.0174532925);
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, 0.0, 0.0);

[self.navigationController.view setTransform:landscapeTransform];

self.navigationController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;    
self.navigationController.view.frame  = CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height);
self.navigationController.view.center  = CGPointMake (384.0, 544.0);

[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft;
}

这是从纵向页面返回后以横向模式显示根页面的屏幕截图,

enter image description here

它应该是这样的

enter image description here

1 回答

  • 1
    -(void)viewWillDisappear:(BOOL)animated
    {
    
    [super viewWillDisappear:animated];
    
    //rotate the page to lansscape
    CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(-90*0.0174532925);
    landscapeTransform = CGAffineTransformTranslate (landscapeTransform, 0.0, 0.0);
    
    [self.navigationController.view setTransform:landscapeTransform];
    
    self.navigationController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;    
    self.navigationController.view.frame  = CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height+64);
    self.navigationController.view.center  = CGPointMake (384.0, 512.0);
    
    [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft;
    
    }
    

    我必须玩这个以调整在纵向模式下此视图消失后出现的横向视图的事情是这样的,

    self.navigationController.view.frame  = CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height+64);
    self.navigationController.view.center  = CGPointMake (384.0, 512.0);
    

    我玩中心点和框架高度来调整它 .

相关问题