viewWillLayoutSubviews 这个函数是切换横竖屏的接口
这个方法在viewcontroller里面响应,view是不响应的
- (void)viewWillLayoutSubviews
{
[self _shouldRotateToOrientation:(UIDeviceOrientation)[UIApplication sharedApplication].statusBarOrientation];
}
-(void)_shouldRotateToOrientation:(UIDeviceOrientation)orientation {
if (orientation == UIDeviceOrientationPortrait ||orientation ==
UIDeviceOrientationPortraitUpsideDown) {
// 竖屏
}else {
// 横屏
}
}