美文网首页iOS Developer
WMPageController Frame 计算不正确 vie

WMPageController Frame 计算不正确 vie

作者: 我们只是GitHub的搬运工 | 来源:发表于2017-06-21 19:01 被阅读60次

新建一个子类继承 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);
}

相关文章

网友评论

    本文标题:WMPageController Frame 计算不正确 vie

    本文链接:https://www.haomeiwen.com/subject/wcvtcxtx.html