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