iOS tableView上下拉刷新

//

//  BFFindFriendMainController.h

//  Chastory

//

//  Created by tf on 13-10-24.

//  Copyright (c) 2013 Gabry. All rights reserved.

//


#import <UIKit/UIKit.h>

#import "PullingRefreshTableView.h"

@interface BFFindFriendMainController : UIViewController

@property (retain, nonatomic) PullingRefreshTableView *myTableView;

//@property (strong ,nonatomic)UITableView * myTableView;

@property (strong ,nonatomic)UIButton * ponitBtn;

@property (assign ,nonatomic) BOOL refreshing;

@end


//

//  BFFindFriendMainController.m

//  Chastory

//

//  Created by tf on 13-10-24.

//  Copyright (c) 2013 Gabry. All rights reserved.

//


#import "BFFindFriendMainController.h"


@interface BFFindFriendMainController ()<UITableViewDataSource,UITableViewDelegate,BFFindFriendMainCellDelegate>

@end


@implementation BFFindFriendMainController


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        //初始化tableView

        //  如果选择plain的样式,则设置的头不会跟着下面的cell走动 cell移动的范围大于头的时候,头才会移动

        //_tableView=[[PullingRefreshTableView alloc]initWithFrame:self.view.bounds pullingDelegate:self];

        self.myTableView = [[PullingRefreshTableView alloc]initWithFrame:CGRectMake(0, 44, self.view.frame.size.width,kScreenHeight) pullingDelegate:self];

        self.myTableView.backgroundColor = Background;

        //取消滚动条

        self.myTableView.showsVerticalScrollIndicator = NO;

        //代理类

        self.myTableView.delegate = self;

        self.myTableView.dataSource = self;

        [self.view addSubview:self.myTableView];

        

    }

    return self;

}


#pragma mark---tableView方法的实现


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    return 2;

}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

    return 1;

}



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    static NSString * string = @"hello";

    BFFindFriendMainCell * cell = [tableView dequeueReusableCellWithIdentifier:string];

    if (cell == nil)

    {

        cell = [[BFFindFriendMainCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:string];

   }

      return cell;

}


-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    CGFloat result = 74.0f;

    if ([tableView isEqual:self.myTableView]){

        result = 74.0f;

    }

    return result;

}


#pragma mark - PullingDelegate

//重新刷新的时候(往下拉)

-(void)pullingTableViewDidStartRefreshing:(PullingRefreshTableView *)tableView{

    self.refreshing = YES;//refreshing的值为yes

    [self performSelector:@selector(loadData) withObject:nil afterDelay:1.f];//调用loadData方法

}


//显示刷新的时间

- (NSDate *)pullingTableViewRefreshingFinishedDate{

    NSDateFormatter * df = [[NSDateFormatter alloc]init];

    df.dateFormat = @"yyyy-MM-dd HH:mm";

    

    NSDate * date = [df dateFromString:@"2012-05-03 10:10"];

    

    return date;

}


//载入数据的时候(往下拉)

- (void)pullingTableViewDidStartLoading:(PullingRefreshTableView *)tableView{

    [self performSelector:@selector(loadData) withObject:nil afterDelay:1.f];

}


- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值