微信扫一扫

028-83195727 , 15928970361
business@forhy.com

iOS开发--UITableView在iPad横屏时两边有很大的空白,解决方法。

ios,ipad,留白,cell空白,tableVie空白2016-11-10

一、问题描述:

iOS9及以上版本,ipad横屏适配cell的时候,出现UITableView两边有很大的空白,效果如下图:

注:这个情况在iPhone中是没有的。

二、解决方法

现在通过设置UITableView的一个属性,就可以解决ipad中的适配问题。

代码如下:

    if ([[UIDevice currentDevice].systemVersion floatValue] >= 9.0)
    {
        self.tableView.cellLayoutMarginsFollowReadableWidth = NO;// 9.0以上才有这个属性,针对ipad。
    }

解决之后的效果图: