(1)效果

(2)源代码与资源下载
http://pan.baidu.com/s/1pJLo2PP
(3)总结
——核心是利用UITableView里面自带的cell来制作样式相同的cell。
与之相应的是,因为不是整个xib文件,所以加载这个cell时有一些区别,只需要在缓存池中取即可(利用ID)。
+(instancetype)cellWithTableView:(UITableView *)tableView{
static NSString *ID=@"app";
WPAppCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
return cell;
}
——第二个知识点,就是判断状态,在赋值的时候也要覆盖新的状态(这里主要是下载按钮的状态),以下第一个方法是赋值时检查状态,第二个方法是点击按钮后按钮状态值改变。
-(void)setApp:(WPApps *)app{
_app=app;
self.icon.image=[UIImage imageNamed:app.icon];
self.name.text=app.name;
self.desc.text=[NSString stringWithFormat:@"%@ | %@",app.size,app.download];
if (!app.isDownloaded) {
self.download.enabled=YES;
}else{
self.download.enabled=NO;
}
}
- (IBAction)clickDownload {
self.download.enabled=NO;
self.app.downloaded=!self.app.isDownloaded;
}
——还有一个万年不变的知识点:代码封装。
本文介绍如何利用UITableView自带的cell创建样式一致的cell,并通过ID在缓存池中快速获取。详细解释了如何判断和更新cell状态,包括下载按钮的启用与禁用。同时强调了代码封装的重要性。
1292

被折叠的 条评论
为什么被折叠?



