第一種:計算高度
label多行顯示,計算size:
cgsize
contentsize = [
fxafactory
fc_getstringsizewith
:str
boundingrectwithsize
:cgsizemake
(kscreen_width
- 30
, maxfloat
) font
:[uifont
systemfontofsize:14
]];第二種:用系統自帶的方法
1、在自定義cell的.m檔案中一定要加上label的寬度
如:self
.detail
.preferredmaxlayoutwidth
= [uiscreen
mainscreen
].bounds
.size
.width
- 20
; 2、在tableview的datasouce中
- (cgfloat
)tableview:(
uitableview
*)tableview heightforrowatindexpath:(
nsindexpath
*)indexpath
第三種:獲取復用的cell後模擬賦值,然後取得cell高度 1
、在自定義cell的.m檔案中一定要加上label的寬度
如:self
.detail
.preferredmaxlayoutwidth
= [uiscreen
mainscreen
].bounds
.size
.width
- 20;
2、 - (
cgfloat
)tableview:(
uitableview
*)tableview heightforrowatindexpath:(
nsindexpath
*)indexpath
如何值通過xib自定義cell
關鍵 如下 uitableviewcell tableview uitableview tableview cellforrowatindexpath nsindexpath indexpath nsinteger row indexpath row cell.textlabel text data...
xib的UIScrollView自適應高度
1 首先,我們先把這個size classes關了 需要使用的童鞋無視掉,也無視掉我的工程名,這是我弄高德地圖建立的工程 2 新增乙個scrollview上去,設定上下左右約束為0 3 然後搞乙個view上去,這就是所有控制項的superview,當然,你搞上去view後是會爆紅的,因為在scorl...
自定義非等高cell01 xib
uitableview中有很多情況下cell的高度是不固定的,這時候cell的高度取決於內容的多少,今天介紹幾個方法來達到自定義非等高cell的效果。lmtestcell.h中加入方法 返回cell 高度 cgfloat cellheight lmtestcell.m中對應方法 cgfloat ce...