国产探花免费观看_亚洲丰满少妇自慰呻吟_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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大英县| 辽源市| 科技| 柘荣县| 都兰县| 当雄县| 柘城县| 许昌市| 太原市| 和林格尔县| 元江| 连城县| 砚山县| 华亭县| 大田县| 武夷山市| 巨野县| 南澳县| 定南县| 若羌县| 道孚县| 刚察县| 华安县| 安多县| 公主岭市| 嘉禾县| 左权县| 哈巴河县| 钟祥市| 苏尼特左旗| 保定市| 藁城市| 米泉市| 武义县| 金门县| 彰武县| 集贤县| 土默特右旗| 丹棱县| 千阳县| 宜川县|