国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

自定義等高的cell

2019-11-09 18:09:47
字體:
來源:轉載
供稿:網友

新建一個繼承自UITableViewCell的子類,比如JCGroupPurchaseCell

@interface JCGroupPurchaseCell : UITableViewCell@end

在JCGroupPurchaseCell.m文件中

重寫-initWithStyle:reuseIdentifier:方法 在這個方法中添加所有的子控件給子控件做一些初始化設置(設置字體、文字顏色等)添加子控件的完整約束/** * 在這個方法中添加所有的子控件 */- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { // ...... } return self;}

在JCGroupPurchaseCell.h文件中提供一個模型屬性,比如JCGroupPurchase模型

@class JCGroupPurchase;@interface JCGroupPurchaseCell : UITableViewCell/** 團購模型數據 */@PRoperty (nonatomic, strong) JCGroupPurchase *groupPurchase;@end

在JCGroupPurchaseCell.m中重寫模型屬性的set方法

在set方法中給子控件設置模型數據- (void)setGroupPurchase:(JCGroupPurchase *)groupPurchase{ _groupPurchase = groupPurchase; // .......}

在控制器中

注冊cell的類型[self.tableView registerClass:[JCGroupPurchaseCell class] forCellReuseIdentifier:ID];給cell傳遞模型數據- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ // 訪問緩存池 JCGroupPurchaseCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; // 設置數據(傳遞模型數據) cell.groupPurchase = self.groupPurchases[indexPath.row]; return cell;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 二手房| 邵阳县| 乐平市| 社旗县| 巴马| 讷河市| 兴义市| 禄丰县| 驻马店市| 太湖县| 盐山县| 从化市| 洪洞县| 田林县| 嘉禾县| 温宿县| 安吉县| 舞阳县| 留坝县| 郁南县| 禄丰县| 梁河县| 邵阳县| 东丰县| 西乌珠穆沁旗| 博湖县| 温宿县| 福州市| 唐山市| 尼玛县| 灵山县| 哈尔滨市| 龙胜| 山东| 龙井市| 尉犁县| 海南省| 盐城市| 吉木萨尔县| 景洪市| 象州县|