[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

Source: Internet
Author: User

[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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.