当我在splashvIEwcontroller中为shouldautorotatetointerfaceorIEntation返回YES时,每个视图都会旋转,因为这是父视图.当我仅在splashvIEw中返回肖像时,即使其他视图返回YES,也不会旋转.有没有办法让视图B旋转?如果你能提供代码,我愿意手动完成.谢谢
解决方法 你可以手动管理任何所需的UIVIEw对象的旋转,如下所示:编辑:
在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中自动旋转?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)