tableview xib下的自適應

2021-07-11 21:01:58 字數 726 閱讀 9002

在xib的新時代,設定好約束一切都可以根據內容自適應.tableview是個例外.

tableview的問題: 1.

tableview在ios7以下是個例外。ios7以下delegate方法

- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath

由於在- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath*)indexpath;方法裡的時候這時候tableview的cell還沒有建立,這裡需要乙個專門用來計算的cell,所以我建立了乙個屬性專門用來存計算的cell. 

ps:這裡只是它的大概實現,當然你必須設定好約束.

封裝之後的庫見:

ios8上的解決方法:

//ios8實現自適應就是這麼簡單,連heightforrowatindexpath方法

都不要實現只要設定好top和bottom約束即可

.self

.maintableview

.estimatedrowheight=40;

self

.maintableview

.rowheight=uitableviewautomaticdimension;

ps:例子:

參考:

linux下的apache mysql自啟動

myslq.server的啟動指令碼程式 複製 etc rc.d init.d目錄 root localhost cd etc rc.d init.d 複製並重命名為mysql root localhost init.d cp usr local mysql support files mysql....

linux下的apache mysql自啟動

myslq.server的啟動指令碼程式 複製 etc rc.d init.d目錄 root localhost cd etc rc.d init.d 複製並重命名為mysql root localhost init.d cp usr local mysql support files mysql....

linux下的apache mysql自啟動

myslq.server的啟動指令碼程式 複製 etc rc.d init.d目錄 root localhost cd etc rc.d init.d 複製並重命名為mysql root localhost init.d cp usr local mysql support files mysql....