IOS-data loading implementation-MJRefresh, ios-load-mjrefresh

Source: Internet
Author: User

IOS-data loading implementation-MJRefresh, ios-load-mjrefresh

Use CocoaPods to load a third-party Library:

pod 'MJRefresh'

 

MJRefresh class structure:


 

Specific implementation methods and:

  • The drop-down refresh 01-Default
    Self. tableView. header = [MJRefreshNormalHeader headerWithRefreshingBlock: ^ {// Call this Block When enter the refresh status automatically}]; or // Set the callback (Once you enter the refresh status, then call the action of target, that is call [self loadNewData]) self. tableView. header = [MJRefreshNormalHeader headerWithRefreshingTarget: self refreshingAction: @ selector (loadNewData)]; // Enter the refresh status immediately [self. tableView. header beginRefreshing];

  • The drop-down refresh 02-Animation image

    // Set the callback (one Once you enter the refresh status, then call the action of target, that is call [self loadNewData]) MJRefreshGifHeader * header = [MJRefreshGifHeader failed: self refreshingAction: @ selector (loadNewData)]; // Set the ordinary state of animated images [header setImages: idleImages forState: MJRefreshStateIdle]; // Set the pulling state of animated images (Enter the status of refreshing as soon as loosen) [header setImages: pullingImages forState: MJRefreshStatePulling]; // Set the refreshing state of animated images [header setImages: refreshingImages forState: MJRefreshStateRefreshing]; // Set headerself. tableView. mj_header = header;

  • The drop-down refresh 03-Hide the time

    // Hide the timeheader.lastUpdatedTimeLabel.hidden = YES;

  • The drop-down refresh 04-Hide status and time

    // Hide the timeheader.lastUpdatedTimeLabel.hidden = YES;// Hide the statusheader.stateLabel.hidden = YES;

  • The drop-down refresh 05-DIY title

    // Set title[header setTitle:@"Pull down to refresh" forState:MJRefreshStateIdle];[header setTitle:@"Release to refresh" forState:MJRefreshStatePulling];[header setTitle:@"Loading ..." forState:MJRefreshStateRefreshing];// Set fontheader.stateLabel.font = [UIFont systemFontOfSize:15];header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:14];// Set textColorheader.stateLabel.textColor = [UIColor redColor];header.lastUpdatedTimeLabel.textColor = [UIColor blueColor];

  • The drop-down refresh 06-DIY the control of refresh
    Self. tableView. mj_header = [MJDIYHeader headerWithRefreshingTarget: self refreshingAction: @ selector (loadNewData)]; // Implementation reference to MJDIYHeader. h and MJDIYHeader. m

  • The pull to refresh 01-Default

    Self. tableView. mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock: ^ {// Call this Block When enter the refresh status automatically}]; or // Set the callback (Once you enter the refresh status, then call the action of target, that is call [self loadMoreData]) self. tableView. mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget: self refreshingAction: @ selector (loadMoreData)];

  • The pull to refresh 02-Animation image

    // Set the callback(Once you enter the refresh status,then call the action of target,that is call [self loadMoreData])MJRefreshAutoGifFooter *footer = [MJRefreshAutoGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];// Set the refresh image[footer setImages:refreshingImages forState:MJRefreshStateRefreshing];// Set footerself.tableView.mj_footer = footer;

  • The pull to refresh 03-Hide the title of refresh status

    // Hide the title of refresh statusfooter.refreshingTitleHidden = YES;// If does have not above method,then use footer.stateLabel.hidden = YES;

  • The pull to refresh 04-All loaded

    //Become the status of NoMoreData[footer noticeNoMoreData];

  • The pull to refresh 05-DIY title

    // Set title[footer setTitle:@"Click or drag up to refresh" forState:MJRefreshStateIdle];[footer setTitle:@"Loading more ..." forState:MJRefreshStateRefreshing];[footer setTitle:@"No more data" forState:MJRefreshStateNoMoreData];// Set fontfooter.stateLabel.font = [UIFont systemFontOfSize:17];// Set textColorfooter.stateLabel.textColor = [UIColor blueColor];

  • The pull to refresh 06-Hidden After loaded

    //Hidden current control of the pull to refreshself.tableView.mj_footer.hidden = YES;

  • The pull to refresh 07-Automatic back of the pull01

    self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];

  • The pull to refresh 08-Automatic back of the pull02

    MJRefreshBackGifFooter *footer = [MJRefreshBackGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];// Set the normal state of the animated image[footer setImages:idleImages forState:MJRefreshStateIdle];//  Set the pulling state of animated images(Enter the status of refreshing as soon as loosen)[footer setImages:pullingImages forState:MJRefreshStatePulling];// Set the refreshing state of animated images[footer setImages:refreshingImages forState:MJRefreshStateRefreshing];// Set footerself.tableView.mj_footer = footer;

  • The pull to refresh 09-DIY the control of refresh (Automatic refresh)

    Self. tableView. mj_footer = [MJDIYAutoFooter notebook: self refreshingAction: @ selector (loadMoreData)]; // Implementation reference to MJDIYAutoFooter. h and MJDIYAutoFooter. m

  • The pull to refresh 10-DIY the control of refresh (Automatic back)

    Self. tableView. mj_footer = [MJDIYBackFooter failed: self refreshingAction: @ selector (loadMoreData)]; // Implementation reference to MJDIYBackFooter. h and MJDIYBackFooter. m

  • UICollectionView01-The pull and drop-down refresh

    // The drop-down refreshself.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{   //Call this Block When enter the refresh status automatically }];// The pull to refreshself.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{   //Call this Block When enter the refresh status automatically}];

  • UIWebView01-The drop-down refresh

    //Add the control of The drop-down refreshself.webView.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{   //Call this Block When enter the refresh status automatically}];

Source: https://github.com/CoderMJLee/MJRefresh

 

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.