大佬教程收集整理的这篇文章主要介绍了iphone – 只有一个视图在xcode中自动旋转?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当我在splashviewcontroller中为shouldautorotatetointerfaceorientation返回YES时,每个视图都会旋转,因为这是父视图.当我仅在splashview中返回肖像时,即使其他视图返回YES,也不会旋转.有没有办法让视图B旋转?如果你能提供代码,我愿意手动完成.谢谢
编辑:
在init或viewDidLoad中
- (void)viewDidLoad { [[NsnotificationCenter defaultCenter] addObserver:self SELEctor:@SELEctor(rotatE) name:UIDeviceOrientationDidChangeNotification object:nil]; [super viewDidLoad]; } #define degreesToRadian(X) (M_PI * (X) / 180.0) -(void)rotate{ self.view.bounds = CGRectMake(0,0); if ([UIDevice currentDevice].orientation == UIInterfaceOrientationPorTrait){ CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(0)); landscapeTransform = CGAffineTransformTranslate (landscapeTransform,0.0,0.0); self.view.bounds = CGRectMake(self.view.bounds.origin.x,self.view.bounds.origin.y,320,480); [self.view setTransform:landscapeTransform]; } else if ([UIDevice currentDevice].orientation == UIInterfaceOrientationPorTraitUpsideDown){ CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(180)); landscapeTransform = CGAffineTransformTranslate (landscapeTransform,480); [self.view setTransform:landscapeTransform]; } else if ([UIDevice currentDevice].orientation == UIInterfaceOrientationLandscapeRight){ CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90)); landscapeTransform = CGAffineTransformTranslate (landscapeTransform,0.0); self.view.bounds = CGRectMake(self.view.bounds.origin.x,480,320); [self.view setTransform:landscapeTransform]; }else if ([UIDevice currentDevice].orientation == UIInterfaceOrientationLandscapeLeft){ CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(270)); landscapeTransform = CGAffineTransformTranslate (landscapeTransform,0.0); self.view.bounds = CGRectMake(self.view.bounds.origin.x,320); [self.view setTransform:landscapeTransform]; } }
以上是大佬教程为你收集整理的iphone – 只有一个视图在xcode中自动旋转?全部内容,希望文章能够帮你解决iphone – 只有一个视图在xcode中自动旋转?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。