iOS Custom Tablefooterview

Source: Internet
Author: User

---------------custom Tablefootviewdelegate class to manage the corresponding xib file----------------#import  <uikit/uikit.h>// This protocol is used to standardize the way in which more data is loaded (more methods need to be loaded in the controller) @protocol  MLTableFooterViewDelegate <NSObject> @optional-( void) Loadingmoredata; @end @interface mltablefooterview : uiview@property (nonatomic ,  Weak) id<mltablefooterviewdelegate> delegate;//is used to quickly create a Footview object. + (Instancetype) footerview;-( Instancetype) Initfooterview, @end #import  "MLTableFooterView.h" @interface  MLTableFooterView  () @ property  (weak, nonatomic)  IBOutlet UIButton *loadBtn; @property   (weak,  nonatomic)  iboutlet uiview *loadingview;-(ibaction) Loadbtnclick; @end @implementation  mltablefooterview+ (instancetype) Footerview{    return [[self alloc] Initfooterview];} -(Instancetype) initfooterview{        //Initializes a nib object that contains all the information in the xib----- Another way to load a xib file      //uinib *nib = [uinib nibwithnibname:@ "Mltablefooterview"  bundle:nil];         //returns an array of all the files in the xib because there is only one in this xib, so Fistobject gets the custom view.     //uiview *footview =  [[nib instantiatewithowner:nil options:nil]  firstobject];        return [[[nsbundle mainbundle]  loadnibnamed:@ "Mltablefooterview"  owner:nil options:nil] firstobject];} -(ibaction) loadbtnclick{    //Hide Load button     self.loadbtn.hidden =  yes;    //Displays the view    self.loadingview.hidden = no; being loaded         //Show more data     //use C language to implement delay (simulate load more)      dispatch_after (Dispatch_time (dispatch_time_now,  (int64_t) (1.0 * NSEC_PER_SEC) ),  dispatch_get_main_queue (),  ^{        if  ([Self.delegate respondstoselector: @selector ( Loadingmoredata)])  {            //load data              [self.delegate loadingMoreData];             //Display Load button              self.loadBtn.hidden = NO;             //hidden "Loading"              self.loadingView.hidden = YES;                     }    });} @end part of the code------------in the////------controller (requires protocol mltablefooterviewdelegate)     // Using a custom tablefooterview    mltablefooterview *footer = [mltablefooterview footerview];    footer.delegate =  self;    //Sets the TableView proxy object to the current class object .     self.tableview.tablefooterview = footer;    //implements the Loadingmoredata method of the protocol, loading more data-( void) loadingmoredata{    //add more model data (virtual data)     mltg *tg =  [[mltg alloc]init];//where MLTG is a model class for my life, _TGS is the object of the controller, which is used to store all the data models .    tg.icon  = @ "ad_00";     tg.title = @ "new added buy data:"; "    tg.price = @";     tg.buycount = @ "0";         //will data _tgs     [_tgs addObject:tg]; in Heaven     //Refresh the table (tells TableView to reload the model data, call TableView Reloaddata)     [ Self.tableview reloaddata];}

iOS Custom Tablefooterview

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.