iOS判断横竖屏

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
    NSLog(@"UIViewController will rotate to Orientation: %ld", toInterfaceOrientation);

    if(([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) || ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)){//横屏
        NSLog(@"横屏");
        self.pyTrendChart.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width);

    }else{//竖屏
        NSLog(@"竖屏");
        self.pyTrendChart.frame = CGRectMake(0, 100, [UIScreen mainScreen].bounds.size.width, 280);
    }
}

自己放在里记录一下,同时也方便别人.

你可能感兴趣的:(iOS判断横竖屏)