2016-05-30 61 views
0

我有UITableViewAutomaticDimension rowHeight的tableview。其中一個單元格包含固定高度的uview。在iOS8上錯誤的tableview行高

內部的視圖的放置兩個按鈕,並在該視圖的LayoutSubviews方法我使用代碼

self.button1.layer.cornerRadius = self.button1.frame.size.height/2 

舍該按鈕。

在iOS9按鈕被正確地呈現:

enter image description here

但是,在iOS8上的按鈕不能正確呈現:

enter image description here

問題是什麼?我必須如何設置約束才能在iOS8中正確呈現按鈕?

這裏小區的.xib文件:

Cell xib file

+0

你在哪裏把cornerRadius設置代碼?我建議你把它放在'layoutSubviews'' – binchik

+0

你應該在視圖中設置角半徑會出現方法,並在它之前調用layoutIfNeeded –

+0

按鈕的高度是多少? –

回答

0

試試這個

這一行添加到您的自定義單元格類

-(void)layoutSubviews 
    { 
     [super layoutSubviews]; 

     self. button1.layer.cornerRadius = self. button1.frame.size. height/2; 
     self. button1.clipsToBounds = YES; 
     [self.contentView layoutIfNeeded]; 
    } 
0

這對我的作品。請嘗試。

self.button1.layer.cornerRadius = self.button1.frame.size.height/2 
self.button1.clipsToBounds = true 

希望這將有助於周到,謝謝