- (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);
}
}
自己放在简书里记录一下,同时也方便别人.