实施iPad常规设置页面

时间:2015-10-26 20:52:06

标签: ios ipad

到目前为止,我已经定制了tableview并实现了iPad General Setting Page。下面是tableview的代码,它将相应地更改框架。但问题是当我在tableview中插入/删除行或节时。我的tableviewcell backgroundview(非单元格)宽度缩小。知道我在这做什么错了吗?

- (void)setFrame:(CGRect)frame
{
    if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
    {
        CGFloat inset =10;
        frame.origin.x += inset;
        frame.size.width -= 2 * inset;//The issue is in this line
    }
    [super setFrame:frame];
}

1 个答案:

答案 0 :(得分:0)

我找到了实现这一目标的简单解决方案。无需自定义UITableView子类。只需取出tableview的出口并设置框架并更改backgroundview的颜色。如下所示: -

CGFloat tableBorderLeft = 10;
CGFloat tableBorderRight = 10;
CGRect tableRect = self.view.frame;
tableRect.origin.x += tableBorderLeft; // make the table begin a few pixels right from its origin
tableRect.size.width -= tableBorderLeft + tableBorderRight; // reduce the width of the table
yourTableView.frame = tableRect;
self.view.backgroundColor=[UIColor colorWithRed:(239/255.0f) green:(239/255.0f) blue:(244/255.0f) alpha:1.0];
相关问题