2015-10-26 82 views
0

到目前爲止,我已經定製了桌面視圖並實現了iPad常規設置頁面。下面是tableview的代碼,它將相應地改變框架。但問題是當我在tableview中插入/刪除行或部分時。我tableviewcell backgroundview(不是單元格)寬度得到收縮。任何想法我在這裏做什麼錯?實現iPad常規設置頁面

- (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]; 
} 
+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];