前一阵子,写了QQ的框架。今天往后,就进行QQ内层VC的设计。
今天就先来说说Message(临时消息视图)的设计。还有,就是上拉下拉得刷新。这是引入了第三方接口。所以继承的父类也是pullTableView.
下载地址:点击打开链接
1.我们先来看看效果
2.首先要声明的是,我并没有使用数据存储(Plist,file。sqlite等)初步只是在viewdidload中初始化了数据。 并且,再点击cell之后,将会跳转到交谈页面
1)h文件
//
// LCMessageViewController.h
// 手机QQ客户端进度1一前期界面
//
// Created by lichan on 13-12-10.
// Copyright (c) 2013年 com.lichan. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "PullTableView.h"
@interface LCMessageViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>
{
PullTableView *myTableView;
}
@property (retain,nonatomic)PullTableView *myTableView;
@property (retain,nonatomic)NSMutableDictionary *dirtionary;
@property (retain,nonatomic)NSMutableArray *userNameArray;
@property (retain,nonatomic)NSMutableArray *userHeadImageArray;
@property (retain,nonatomic)NSMutableArray *userZoneSayArray;
@property (retain,nonatomic)NSMutableArray *userLoginTimeArray;
@property (retain,nonatomic)UISearchBar *searchBar;
@end
2)m文件。
//
// LCMessageViewController.m
// 手机QQ客户端进度1一前期界面
//
// Created by lichan on 13-12-10.
// Copyright (c) 2013年 com.lichan. All rights reserved.
//
#import "LCMessageViewController.h"
#import "LCDialogueViewController.h"
@interface LCMessageViewController ()
@end
@implementation LCMessageViewController
@synthesize myTableView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.backgroundColor = [UIColor blackColor];
self.userHeadImageArray = [NSMutableArray arrayWithObjects:[UIImage imageNamed:@"111.png"],[UIImage imageNamed:@"112.png"],[UIImage imageNamed:@"110.png"],[UIImage imageNamed:@"114.png"],[UIImage imageNamed:@"115.png"],[UIImage imageNamed:@"116.png"],[UIImage imageNamed:@"117.png"],[UIImage imageNamed:@"118.png"],[UIImage imageNamed:@"119.png"],[UIImage imageNamed:@"113.png"], nil];
self.userLoginTimeArray = [NSMutableArray arrayWithObjects:@"14:59",@"一天前",@"一天前",@"一天前",@"一天前",@"一天前",@"一天前",@"一天前",@"一天前",@"一天前", nil];
self.userNameArray =[NSMutableArray arrayWithObjects:@"赵屌屌",@"阳仔",@"大黄",@"老二",@"冬冬",@"胖子",@"大葱",@"小娜",@"妹纸",@"憨货", nil];
self.userZoneSayArray =[NSMutableArray arrayWithObjects:@"你好",@"helloworld",@"helloworld",@"狗",@"helloworld",@"咋",@"good",@"一天",@"考试",@"鼠标", nil];
self.myTableView = [[PullTableView alloc]initWithFrame:CGRectMake(0, 0, 320, 460) style:UITableViewStylePlain];
self.myTableView.delegate = self;
self.myTableView.dataSource =self;
[self.view addSubview:self.myTableView];
//添加搜索bar
self.searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 60, 320, 44)];
self.searchBar.placeholder = @"搜索";
[self.view addSubview:self.searchBar];
// Do any additional setup after loading the view.
}
#pragma mark UITableViewDataSource methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.userNameArray.count;
}
// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MessageCell = @"MessageCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MessageCell];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:MessageCell];
}
NSInteger row = [indexPath row];
UIImage *image = [self.userHeadImageArray objectAtIndex:row];
cell.imageView.image = image;
cell.textLabel.text = [self.userNameArray objectAtIndex:row];
cell.detailTextLabel.text = [self.userZoneSayArray objectAtIndex:row];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 20)];
label.text = [self.userLoginTimeArray objectAtIndex:row];
label.textColor = [UIColor grayColor];
cell.accessoryView = label;
return cell;
}
#pragma mark UITableView delegate Methods
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 60;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
LCDialogueViewController *dialogueVC = [[LCDialogueViewController alloc]init];
[self presentViewController:dialogueVC animated:YES completion:nil];
}
//导入第三方包实现的delegate协议
#pragma mark - PullTableViewDelegate
- (void)pullTableViewDidTriggerRefresh:(PullTableView *)pullTableView
{
[self performSelector:@selector(refreshTable) withObject:nil afterDelay:3.0f];
}
- (void)pullTableViewDidTriggerLoadMore:(PullTableView *)pullTableView
{
[self performSelector:@selector(loadMoreDataToTable) withObject:nil afterDelay:3.0f];
}
- (void) refreshTable
{
/*
Code to actually refresh goes here.
*/
self.myTableView.pullLastRefreshDate = [NSDate date];
self.myTableView.pullTableIsRefreshing = NO;
}
- (void) loadMoreDataToTable
{
/*
Code to actually load more data goes here.
*/
self.myTableView.pullTableIsLoadingMore = NO;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//如果没有刷新,则进行刷新操作
if(!self.myTableView.pullTableIsRefreshing) {
self.myTableView.pullTableIsRefreshing = YES;
[self performSelector:@selector(refreshTable) withObject:nil afterDelay:3.0f];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end