新建一個子類繼承 WMPageController
.M關鍵代碼文件如下
#pragma mark 解決適配iOS 8.x 系統橫屏問題
-(void)viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
// if(IOS9Later) return;
UIInterfaceOrientation interfaceOrientation=[[UIApplication sharedApplication] statusBarOrientation];
if (interfaceOrientation == UIDeviceOrientationPortrait || interfaceOrientation == UIDeviceOrientationPortraitUpsideDown) {
//翻轉為豎屏時
[self setVerticalFrame];
}else if (interfaceOrientation==UIDeviceOrientationLandscapeLeft || interfaceOrientation == UIDeviceOrientationLandscapeRight) {
//翻轉為橫屏時
[self setHorizontalFrame];
}
}
//這里的frame size根據值項目中的大小來自定義
-(void)setVerticalFrame
{
///豎屏
self.viewFrame = CGRectMake(0, 64,ScreenWidth ,ScreenHeight-64);
}
-(void)setHorizontalFrame
{
///橫屏
self.viewFrame = CGRectMake(0, 32,ScreenWidth , ScreenWidth-320);
}