MJ刷新加MJE解析

首先创建工程 在工程中导入 AFN MJE MF

在viewcontroller.m里

#import "ViewController.h"
#import "AFNetworking.h"
#import "MJExtension.h"
#import "Model.h"
#import "MJRefresh.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *tbv;
@property(nonatomic,strong)NSMutableArray *datasource;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self jiexi];
    [self.view addSubview:self.tbv];
    
    [self loadbata];
}
-(void)loadbata{
    
    self.tbv.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    // 马上进入刷新状态
    [self.tbv.mj_header beginRefreshing];
    
    
}
-(void)loadNewData{
    
}
-(void)jiexi{

  AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:@"http://test.bit.api.meeboo.cc/?method=app.news.getarticlelist&class_id=3&_debug=Y" parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
 self.datasource =[Model mj_objectArrayWithKeyValuesArray:responseObject[@"data"][@"list"]];
        [self.tbv reloadData];
    
        [self.tbv.header endRefreshing];
        NSLog(@"JSON: %@", responseObject);
    } failure:^(NSURLSessionTask *operation, NSError *error) {
        NSLog(@"Error: %@", error);
    }];
}
-(UITableView *)tbv{
    if (!_tbv)
    {
        _tbv=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    }
    _tbv.delegate=self;
    _tbv.dataSource=self;
    return _tbv;
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return _datasource.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString*str=@"str";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:str];
    if (!cell)
    {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:str];
    }
    Model *md=_datasource[indexPath.row];
    cell.textLabel.text=md.title;
    cell.detailTextLabel.text=md.author;
    return cell;
}

@end



model里写


@property(nonatomic,strong)NSString *title,*author,*create_time;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值