//
// 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