ios MJRefresh 上拉死循环刷新问题+git 图片

 网上各种办法都试了,只有这种解决方法解决了我的问题,记录一下

 

通过延迟 1s后,再来请求接口

 

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view.

 

    self.currentPage = 1;

    

    if (@available(iOS 11.0, *)) {

        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

    } else {

        self.tableView.translatesAutoresizingMaskIntoConstraints = false;

    }

    

    [self addHeaderMJ];

    [self addFooterMJ];

    [self loadTopicDetailListWithLastID:@""];

}

#pragma mark - 懒加载 tableView

-(ZBS_YKZL_TableView *)tableView{

    if (_tableView == nil) {

        ZBS_YKZL_TableView *tableView = [ZBS_YKZL_TableView contentTableViewWithFrame:CGRectMake(0, 0, Screen_Width, Screen_Height-JYEStatusAndNavigationBarHeight64)];

        [self.view addSubview:tableView];

        _tableView = tableView;

    }

    return _tableView;

}

#pragma mark -刷新界面和加载更多

- (void)addHeaderMJ{

    //下拉刷新

    MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshData:)];

    [header setTitle:@"" forState:MJRefreshStateIdle];

    [header setTitle:@"松开即刷新" forState:MJRefreshStatePulling];

    [header setTitle:@"刷新中..." forState:MJRefreshStateRefreshing];

    header.lastUpdatedTimeLabel.hidden = YES;

    self.tableView.mj_header = header;

    

    [self.tableView.mj_header beginRefreshing];

}

 

- (void)addFooterMJ{

    //上拉加载

    MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(downloadNewData:)];

    [footer setTitle:@"" forState:MJRefreshStateIdle];

    [footer setTitle:@"松开即加载" forState:MJRefreshStatePulling];

    [footer setTitle:@"加载中..." forState:MJRefreshStateRefreshing];

    self.tableView.mj_footer = footer;

}

//刷新数据

- (void)refreshData:(MJRefreshNormalHeader *)header {

    self.currentPage = 1;

    if (self.modelListArray.count) {

        [self.modelListArray removeAllObjects];

    }

    [header beginRefreshing];

    [self performSelector:@selector(delayRefresh) withObject:nil afterDelay:1];

//    [self loadTopicDetailListWithLastID:@""];

}

-(void)delayRefresh{

    [self loadTopicDetailListWithLastID:@""];

}

 

//加载数据

- (void)downloadNewData:(MJRefreshAutoNormalFooter *)footer {

    self.currentPage++;

    ZBS_YKZL_TableViewModel *model = [self.modelListArray lastObject];

    NSString *lastID = model.ID;

    [footer beginRefreshing];

    [self loadTopicDetailListWithLastID:lastID];

}

 

 

--------------------------------------------------------------------------------------------

iOS gif图显示问题

转载:https://www.cnblogs.com/AliliWl/p/4895285.html

posted @ 2020-09-06 13:19  偶阵雨ss33  Views(281)  Comments(0Edit  收藏  举报