美文网首页
自定义UIPresentationController弹出页面上

自定义UIPresentationController弹出页面上

作者: koreadragon | 来源:发表于2018-04-10 14:08 被阅读38次

    具体体现为在present之后是没有问题的,如果页面上有UITextField时,在编辑完成键盘消失后,页面会上移一下,导致布局错乱。
    原因就是在代理方法返回presented controller页面的rect时,高度一定是总的页面高度减去头部空隙,不能既头部有空隙,高度又是全部高度。

    - (CGRect)frameOfPresentedViewInContainerView{
    
        CGRect frame = [UIApplication sharedApplication].statusBarFrame;
        CGFloat height = [UIScreen mainScreen].bounds.size.height;
        CGFloat width = [UIScreen mainScreen].bounds.size.width;
        //正确
        CGRect rect = CGRectMake(0,frame.size.height, width, height-frame.size.height);
        //错误
        //CGRect rect = CGRectMake(0,frame.size.height, width, height);
        return rect;
    }
    

    相关文章

      网友评论

          本文标题:自定义UIPresentationController弹出页面上

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