iOS系统的判定,这个可以通过
[[[UIDevice currentDevice] systemVersion] floatValue]来获得。
#pragma mark -----
设置旋转功能
-----------
#if 0
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return toInterfaceOrientation;
}
#endif
#if 1
/*
以前的方法不调用,改为下面的方法,并追加了一个
NSUInterger
返回值的方法
*/
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortraitUpsideDown|UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskLandscapeRight;
}
#endif
#pragma mark ----
屏幕旋转后调用函数
-------
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{
if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft||toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
_segmentControl.frame = CGRectMake(0, _rect.size.width-100, _rect.size.height, 50);
_imageView.frame = CGRectMake(0, 0, _rect.size.height, _rect.size.width);
}else{
_segmentControl.frame = CGRectMake(0, _rect.size.height-100, _rect.size.width, 50);
_imageView.frame = CGRectMake(0, 0, _rect.size.width, _rect.size.height);
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end