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

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

自定義等高的cell

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

新建一個繼承自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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柳江县| 平南县| 和顺县| 酉阳| 河北区| 苍南县| 昌邑市| 平潭县| 哈密市| 阿巴嘎旗| 南乐县| 图们市| 长顺县| 太谷县| 南丹县| 汝州市| 凤台县| 梨树县| 威宁| 涪陵区| 杭锦后旗| 玛曲县| 广宗县| 潞城市| 伊金霍洛旗| 涡阳县| 惠东县| 张家口市| 舟山市| 珠海市| 天柱县| 垣曲县| 绿春县| 青铜峡市| 郑州市| 北安市| 丘北县| 唐海县| 长治县| 托克逊县| 龙泉市|