tableview cell自適應無需計算
充分利用了Masonry 三方庫
https://github.com/xiaoniu-xie/AutoCellHeight.git
1.效果圖

張小牛.png
2.建立tableView 設定行高
table.estimatedRowHeight = 50;
3.tableViewCell的行高設定三行程式碼
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
cell.separatorInset = UIEdgeInsetsZero;
cell.layoutMargins = UIEdgeInsetsZero;
cell.preservesSuperviewLayoutMargins = NO;
}
4.自定義一個tableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[TableViewCell reuseIdentifier]];
if (!cell) {
cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[TableViewCell reuseIdentifier]];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.content.text = newContent;
return cell;
}
5.自定義的tableViewCell中mas_equalTo就是對應的需要自適應的地方
self.content = [[UILabel alloc]init];
self.content.numberOfLines = 0;
self.content.backgroundColor = ZXNColor(70, 122, 142, 1);
self.content.textColor = ZXNColor(240, 195, 79, 1);
[self addSubview:self.content];
[self.content mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(leftImageView.mas_right).offset(10);
make.right.mas_equalTo(rightImageView.mas_left).offset(-10);
make.top.equalTo(@10);
make.bottom.equalTo(@-10);
}];
相關文章
- iOS初級開發學習筆記:一個頁面中自動計算cell的高度來自適應tableView的高度iOS筆記View
- display:table-cell自適應佈局
- IOS多型別Cell的tableView實現iOS多型型別View
- Swift iOS : 如果Cell內部有webview怎麼自適應呢SwiftiOSWebView
- 自適應介面設計
- 短視訊平臺原始碼,彈性佈局實現自適應高度cell原始碼
- 自適應案例
- 複雜性自適應系統無法建模分析
- textarea 高度自適應
- 圖片自適應
- JFrame自適應大小
- 自適應辛普森法
- vue前端自適應佈局,一步到位所有自適應Vue前端
- css自適應佈局CSS
- web自適應尺寸方法Web
- Android 螢幕自適應Android
- html iframe高度自適應HTML
- LMS自適應濾波
- 好程式設計師web前端分享高度自適應程式設計師Web前端
- web的高度計算-cell-裡面使用-只做記錄Web
- 前端學習之路之自適應設計(sass語法)前端
- textarea文域高度自適應
- textarea高度自適應詳解
- 元素自適應水平垂直居中
- 小程式Swiper高度自適應
- jQuery textarea框高度自適應jQuery
- Android 8.0 自適應圖示Android
- c# 窗體自適應C#
- Oracle 11.1 自適應遊標Oracle
- 思路:element 表格元件自適應元件
- gridview自動適應列寬View
- iframe 跨域高度自適應跨域
- 自適應CFAR檢測器
- 前端:WebP自適應實踐前端Web
- 自動載入的iframe高度自適應
- Qt如何寫一個三秒自動消失提示窗,適用於窗體和tableView中QTView
- 響應式圖片(自適應圖片)
- QTableWidget行高列寬自適應QT
- input文字框寬度自適應