2013-03-06 44 views
-1

我有分組uitableview的設計問題,我將uiviews添加到每個單元格的最左邊,延伸的單元格邊界很少,我希望它們被剪裁。但是在IB中設置剪輯子視圖和在代碼中設置clipsToBounds屬性都沒有幫助。分組樣式UITableView不會剪裁子視圖

到目前爲止,我還設置clipsToBounds(兩者的UITableView本身和個人uitabviewcells)在許多地方,但沒有幫助:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    ... 
    [cell setClipsToBounds:TRUE]; 
} 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:defaultIdentifier]; 

    if (cell == nil) 
    { 
     cell = [self reuseTableViewCellWithIdentifier:defaultIdentifier withIndexPath:indexPath]; 
    } 
    ... 
    [cell setClipsToBounds:TRUE]; 
    ... 
    return cell; 
} 

- (void)viewDidLoad 
{ 
    ... 
    [mainTableView setClipsToBounds:TRUE]; 
} 

是否有可能在不改變的tableview風格平淡?

+0

Try cell.contentView.clipsToBounds = YES; (這是一個猜測) – danh 2013-03-07 00:21:26

+0

有截圖嗎? 「單元格」是表格的全部寬度(即,它包括左/右的灰色位)。 – 2013-03-07 00:24:18

回答

0

更新:我以前的回答是錯誤的。這裏的答案實際上表明瞭如何去做你所要求的。

https://stackoverflow.com/a/401271/350467

.......

以前的答案

如果您添加欣賞到單元格的內容查看(你是應該的,除非你有一個很好的理由),你會想要設置cell.contentView.clipsToBounds = YES;