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

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

在此处输入图像描述

这就是它的样子

在此处输入图像描述

4

1 回答 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);

我玩弄了中心点和框架高度来调整它。

于 2012-06-23T04:18:29.423 回答