iOS Dev-68 app download case: Take advantage of TableView's cell layout + cache pool Cell Reuse Note button State check

Source: Internet
Author: User

(1) Effect



(2) Source code and resources download

Http://pan.baidu.com/s/1pJLo2PP


(3) Summary

The core is to use the cell inside the UITableView to make the same cell.


Correspondingly, because it is not the entire xib file, there are some differences when loading the cell, just take it from the cache pool (using the ID).

+ (Instancetype) Cellwithtableview: (UITableView *) tableview{    static nsstring *[email protected] "app";    Wpappcell *cell=[tableview Dequeuereusablecellwithidentifier:id];    return cell;}

The second knowledge point, is the state of judgment, in the assignment of the time to overwrite the new state (here is mainly the status of the download button), the following first method is assigned to check the status, the second method is to click the button after the button state value changes.

-(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 a perpetual knowledge point: Code encapsulation.

iOS Dev-68 app download case: Take advantage of TableView's cell layout + cache pool Cell Reuse Note button State check

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.