新建一個繼承自UITableViewCell
的子類,比如XMGTgCell
@interface XMGTgCell : UITableViewCell
@end
在storyboard文件中,找到UITableView里面的cell(動態cell)
@interface XMGTgCell()
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *buyCountLabel;
@end
在XMGTgCell.h文件中提供一個模型屬性,比如XMGTg模型
@class XMGTg;
@interface XMGTgCell : UITableViewCell
/** 團購模型數據 */
@property (nonatomic, strong) XMGTg *tg;
@end
在XMGTgCell.m中重寫模型屬性的set方法
- (void)setTg:(XMGTg *)tg
{
_tg = tg;
// .......
}
在控制器中
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *ID = @"tg";
// 訪問緩存池
XMGTgCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
// 設置數據(傳遞模型數據)
cell.tg = self.tgs[indexPath.row];
return cell;
}
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。