[IOS development-68] APP download case: Check the button status when using the cell Layout that comes with tableView + the cache pool cell,-68 tableview
(1) Effect
(2) source code and resource download
Http://pan.baidu.com/s/1pJLo2PP
(3) Summary
-- The core is to use the cell in the UITableView to create cells with the same style.
Correspondingly, because it is not the entire xib file, there are some differences when loading this cell. You only need to obtain it in the cache pool (using ID ).
+(instancetype)cellWithTableView:(UITableView *)tableView{ static NSString *ID=@"app"; WPAppCell *cell=[tableView dequeueReusableCellWithIdentifier:ID]; return cell;}
-- The second knowledge point is to judge the status. When assigning values, it must overwrite the new status (here it is mainly the status of the Download button). The first method below is to check the status when assigning values, the second method is to change the status value after clicking the button.
-(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;}
-- There is still a 10 thousand-year-old knowledge point: Code encapsulation.