- (void)viewDidLoad
{
[superviewDidLoad];
NSLog(@"%f,%f", kScreenWidth, kScreenHeight);
imgV= [[UIImageViewalloc] initWithImage:[UIImageimageNamed:@"Default.png"]];
UIInterfaceOrientationinterfaceOrientation=[[UIApplicationsharedApplication] statusBarOrientation];
if (interfaceOrientation == UIDeviceOrientationPortrait || interfaceOrientation == UIDeviceOrientationPortraitUpsideDown) {
//翻转为竖屏时
imgV.frame =CGRectMake(0, 0,kScreenWidth, 300);
}elseif (interfaceOrientation==UIDeviceOrientationLandscapeLeft || interfaceOrientation == UIDeviceOrientationLandscapeRight) {
//翻转为横屏时
imgV.frame =CGRectMake(0, 0,kScreenHeight, 300);
}
[self.view addSubview:imgV];
}
//ios6
-(NSUInteger)supportedInterfaceOrientations{
returnUIInterfaceOrientationMaskAll;
}
//ios6
- (BOOL)shouldAutorotate {
returnYES;//支持转屏
}
//ios5
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
returnYES;
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
switch (interfaceOrientation) {
caseUIInterfaceOrientationPortrait:
NSLog(@"home健在下");
imgV.frame =CGRectMake(0, 0,kScreenWidth, 300);
break;
caseUIInterfaceOrientationPortraitUpsideDown:
NSLog(@"home健在上");
imgV.frame =CGRectMake(0, 0,kScreenWidth, 300);
break;
caseUIInterfaceOrientationLandscapeLeft:
NSLog(@"home健在左");
imgV.frame =CGRectMake(0, 0,kScreenHeight, 300);
break;
caseUIInterfaceOrientationLandscapeRight:
NSLog(@"home健在右");
imgV.frame =CGRectMake(0, 0,kScreenHeight, 300);
break;
default:
break;
}
}