程序中有的view需要自动旋转,其它的不需要自动旋转。之前的实现在ios5里挺好,但在ios6下不行。
参考了
http://stackoverflow.com/questions/12546498/ios-6-auto-rotate-confusion
http://stackoverflow.com/questions/12553754/ios-6-auto-rotation-issue-supportedinterfaceorientations-return-value-not-resp
在navigationcontroller里添加
-(NSUInteger) supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
在不需要旋转的viewcontroller里添加
//这个函数是为了和之前的ios兼容
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}