uitableview仿qq好友分组怎样实现收缩jquery展开收缩效果页面

&UITableView 仿QQ空间列表布局
秒后自动跳转到登录页
快捷登录:
举报类型:
不规范:上传重复资源
不规范:标题与实际内容不符
不规范:资源无法下载或使用
其他不规范行为
违规:资源涉及侵权
违规:含有危害国家安全等内容
违规:含有反动/色情等内容
违规:广告内容
详细原因:
任何违反下载中心规定的资源,欢迎Down友监督举报,第一举报人可获5-10下载豆奖励。
视频课程推荐
UITableView 仿QQ空间列表布局
上传时间:
技术分类:
资源评价:
(0位用户参与评价)
已被下载&25&次
通过自定义Cell 仿QQ空间列表布局 。测试环境:Xcode 6.0,iOS 6.0以上
本资料共包含以下附件:
UITableView 仿QQ空间列表布局.zip
51CTO下载中心常见问题:
1.如何获得下载豆?
1)上传资料
2)评论资料
3)每天在首页签到领取
4)购买VIP会员服务,无需下载豆下载资源
5)更多途径:点击此处
2.如何删除自己的资料?
下载资料意味着您已同意遵守以下协议:
1.资料的所有权益归上传用户所有
2.未经权益所有人同意,不得将资料中的内容挪作商业或盈利用途
3.51CTO下载中心仅提供资料交流平台,并不对任何资料负责
4.本站资料中如有侵权或不适当内容,请邮件与我们联系()
5.本站不保证资源的准确性、安全性和完整性, 同时也不承担用户因使用这些资料对自己和他人造成任何形式的伤害或损失
相关专题推荐
Unity3D是一个让你轻松创作的多平台的
本专题为JavaME手机开发大全视频教程
就目前趋势来看,移动互联网的规模将
去年被Facebook收购的Instagram,最吸
Coding Together: Developing Apps f
本专题由关东升老师讲解,共15讲37课
最有含金量量的iOS培训教程,李明杰老
本专题为传智播客发布的iOS教学视频,
iOS 7是美国苹果公司开发的手机和[1]
本专题为传智播客最新推出的iOS开发进
本专题为关东升老师主讲的iPhone和iP
iOS 具有简单易用的界面、令人惊叹的
本专题为swift语言学习专题,内含有完
关于iPhone SDK和iPhone开发的基础教
iphone开发视频教程iphone开发视频教
本教程为IOS手机端控件级开发的全套视
意见或建议:
联系方式:
您已提交成功!感谢您的宝贵意见,我们会尽快处理UITableView 仿QQ空间列表布局
查看次数:7657
下载次数:3745
上传时间:
大小:145 B
通过自定义Cell 仿QQ空间列表布局 。
测试环境:Xcode 6.0,iOS 6.0以上
您还没有登录!请或
下载过该代码的还下载了
本周热门下载
&2017 Chukong Technologies,Inc.
京公网安备89本帖子已过去太久远了,不再提供回复功能。需求:类似于QQ好友列表页面的显示,有好友分组,有好友数量,在线人数,vip会员、展开分组时显示分组好友,合并分组时不显示:具体效果图如下:
1、展开分组时显示分组好友,该功能可以使用显示UITableViewCell的数据即可;
2、分组头可以考虑使用一个headerView来实现;
示例文件结构:
具体实现步骤:
1、自定义数据模型类,由于plist文件中包含了2个字典,所以需要写2个数据模型;
2、自定义cell,属性包括数据模型以及生成可重用cell的方法,由于系统自带的子控件即可满足实际要求,所以不用写frame模型了;
4、自定义HeaderView,包括模型数据属性和快速构造HeaderView的类方法,以及代理方法;
5、在控制器中写UITableView的 数据显示的方法;
具体代码:
JWFriend.h
12-24-FriendGroup
Created by xiaomoge on 14/12/24.
Copyright (c) 2014年 xiaomoge. All rights reserved.
9 #import &Foundation/Foundation.h&
11 @interface JWFriend : NSObject
12 @property (nonatomic,copy) NSString *
13 @property (nonatomic,copy) NSString *
14 @property (nonatomic,copy) NSString *
15 @property (nonatomic,assign,getter=isVip) BOOL
16 - (instancetype)initWithDic:(NSDictionary *)
17 + (instancetype)friendWithDic:(NSDictionary *)
JWFriend.m
12-24-FriendGroup
Created by xiaomoge on 14/12/24.
Copyright (c) 2014年 xiaomoge. All rights reserved.
9 #import "JWFriend.h"
11 @implementation JWFriend
12 - (instancetype)initWithDic:(NSDictionary *)dic {
if (self = [super init]) {
[self setValuesForKeysWithDictionary:dic];//KVC的使用
18 + (instancetype)friendWithDic:(NSDictionary *)dic {
return [[self alloc] initWithDic:dic];
JWFriendGroup.h
12-24-FriendGroup
Created by xiaomoge on 14/12/24.
Copyright (c) 2014年 xiaomoge. All rights reserved.
9 #import &Foundation/Foundation.h&
11 @interface JWFriendGroup : NSObject
12 @property (nonatomic,strong) NSArray *
13 @property (nonatomic,copy) NSString *
14 @property (nonatomic,assign)
组头是否展开,默认为NO
18 @property (nonatomic,assign,getter=isExpend) BOOL
19 - (instancetype)initWithDic:(NSDictionary *)
20 + (instancetype)friendGroupWithDic:(NSDictionary *)
21 + (NSMutableArray *)friendGroupL
JWFriendGroup.m
12-24-FriendGroup
Created by xiaomoge on 14/12/24.
Copyright (c) 2014年 xiaomoge. All rights reserved.
9 #import "JWFriendGroup.h"
10 #import "JWFriend.h"
11 @implementation JWFriendGroup
12 - (instancetype)initWithDic:(NSDictionary *)dic {
if (self = [super init]) {
[self setValuesForKeysWithDictionary:dic];
18 + (instancetype)friendGroupWithDic:(NSDictionary *)dic {
return [[self alloc] initWithDic:dic];
22 + (NSMutableArray *)friendGroupList {
NSArray *array = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"friends" ofType:@"plist"]];
NSMutableArray *tempArray = [NSMutableArray array];
for (NSDictionary *dic in array) {//字典转模型
JWFriendGroup *friendGroup = [JWFriendGroup friendGroupWithDic:dic];
NSMutableArray *tem = [NSMutableArray array];
for (NSDictionary *dict in friendGroup.friends) {//模型里面还带有子弹,所以继续进行字典转模型步骤
JWFriend *friend = [JWFriend friendWithDic:dict];
[tem addObject:friend];
friendGroup.friends =//转完模型后记得重新赋值
[tempArray addObject:friendGroup];
return tempA
JWFriendCell.h
12-24-FriendGroup
Created by xiaomoge on 14/12/24.
Copyright (c) 2014年 xiaomoge. All rights reserved.
9 #import &UIKit/UIKit.h&
10 @class JWF
11 @interface JWFriendCell : UITableViewCell
12 @property (nonatomic,strong) JWFriend *friendD
13 + (instancetype)cellWithTableView:(UITableView *)tableV
JWFriendCell.m
12-24-FriendGroup
Created by xiaomoge on 14/12/24.
Copyright (c) 2014年 xiaomoge. All rights reserved.
9 #import "JWFriendCell.h"
10 #import "JWFriend.h"
11 @implementation JWFriendCell
12 //快速构造一个可重用的cee
13 + (instancetype)cellWithTableView:(UITableView *)tableView {
static NSString *resue = @"cell";
JWFriendCell *cell = [tableView dequeueReusableCellWithIdentifier:resue];
if (!cell) {
cell = [[self alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:resue];
21 //重写set方法,给各子控件赋值
22 - (void)setFriendDatas:(JWFriend *)friendDatas {
_friendDatas = friendD
self.textLabel.text = friendDatas.
self.detailTextLabel.text = friendDatas.
self.imageView.image = [UIImage imageNamed:friendDatas.icon];
self.textLabel.textColor = friendDatas.isVip ? [UIColor redColor] : [UIColor blackColor];//如果是vip,那么呢称字体为红色
JWFriendHeaderView.h
12-24-FriendGroup
Created by xiaomoge on 14/12/24.
Copyright (c) 2014年 xiaomoge. All rights reserved.
9 #import &UIKit/UIKit.h&
10 @class JWFriendGroup,JWFriendHeaderV
11 @protocol JWFriendHeaderViewDelegate &NSObject&
12 @optional
13 - (void)clickNameBtn:(JWFriendHeaderView *)headerV
16 @interface JWFriendHeaderView : UITableViewHeaderFooterView
17 @property (nonatomic,strong) JWFriendGroup *friendG
18 @property (nonatomic,assign) id&JWFriendHeaderViewDelegate&
19 + (instancetype)headerViewWithTableView:(UITableView *)tableV
JWFriendHeaderView.m
12-24-FriendGroup
Created by xiaomoge on 14/12/24.
Copyright (c) 2014年 xiaomoge. All rights reserved.
9 #import "JWFriendHeaderView.h"
10 #import "JWFriendGroup.h"
11 @interface JWFriendHeaderView ()
12 @property (nonatomic,weak) UIButton *nameV
13 @property (nonatomic,weak) UILabel *countL
15 @implementation JWFriendHeaderView
16 //快速构造一个可重用的组头
17 + (instancetype)headerViewWithTableView:(UITableView *)tableView {
static NSString *resue = @"head";//缓存池标识
JWFriendHeaderView *headerView = [tableView dequeueReusableCellWithIdentifier:resue];
if (!headerView) {
headerView = [[self alloc] initWithReuseIdentifier:resue];
return headerV
25 //重写方法,初始化控件
26 - (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
UIButton *nameBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[self.contentView addSubview:nameBtn];
self.nameView = nameB
//按钮的一些属性的设置
[nameBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[nameBtn setImage:[UIImage imageNamed:@"buddy_header_arrow"] forState:UIControlStateNormal];
[nameBtn setBackgroundImage:[UIImage imageNamed:@"buddy_header_bg"] forState:UIControlStateNormal];
[nameBtn setBackgroundImage:[UIImage imageNamed:@"buddy_header_bg_highlighted"] forState:UIControlStateHighlighted];
nameBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);//按钮内容的间距,左间距为10
nameBtn.titleEdgeInsets =
UIEdgeInsetsMake(0, 10, 0, 0);//文字内容的间距,左间距为10
nameBtn.imageView.contentMode = UIViewContentModeC//不缩放按钮图片
nameBtn.imageView.clipsToBounds = NO;//图片超出部分不裁剪
nameBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentL//设置左对齐
[nameBtn addTarget:self action:@selector(nameClick) forControlEvents:UIControlEventTouchUpInside];//注册按钮点击事件
UILabel *countLabel
= [[UILabel alloc] init];
[self.contentView addSubview:countLabel];
self.countLabel = countL
//文本标签的一些属性的设置
countLabel.textAlignment = NSTextAlignmentR
countLabel.font = [UIFont systemFontOfSize:14];
countLabel.textColor = [UIColor grayColor];
53 //这个方法改变了组头的frame后就会调用,那么可以在这里设置frame了
54 - (void)layoutSubviews {
[super layoutSubviews];//记得必须先实现父类的该方法
self.nameView.frame = self.
CGFloat countX = self.bounds.size.width - 10 - 150;
self.countLabel.frame = CGRectMake(countX, 0, 150, 44);
60 //点击组头按钮事件
61 - (void)nameClick {
self.friendGroup.expend = !self.friendGroup.isE//获取组头是否展开状态
[self expend];//调用封装的一个方法,如果展开,那么图片旋转90度,否则不展开
if ([self.delegate respondsToSelector:@selector(clickNameBtn:)]) {//通知代理,点击了组头按钮
[self.delegate clickNameBtn:self];
68 //重写set方法,给各控件赋值
69 - (void)setFriendGroup:(JWFriendGroup *)friendGroup {
_friendGroup = friendG//这句记得写,否则会造成没有内容显示
[self.nameView setTitle:friendGroup.name forState:UIControlStateNormal];
self.countLabel.text = [NSString stringWithFormat:@"%d/%lu",friendGroup.online,(unsigned long)friendGroup.friends.count];
[self expend];//调用封装的一个方法,如果展开,那么图片旋转90度,否则不展开
75 //封装的方法,如果展开,那么图片旋转90度,否则旋转度为0
76 - (void)expend {
CGFloat angle = self.friendGroup.isExpend ? M_PI_2 : 0;
[UIView animateWithDuration:0.5 animations:^{
self.nameView.imageView.transform = CGAffineTransformMakeRotation(angle);
Controller:
ViewController.m
12-24-FriendGroup
Created by xiaomoge on 14/12/24.
Copyright (c) 2014年 xiaomoge. All rights reserved.
9 #import "ViewController.h"
10 #import "JWFriend.h"
11 #import "JWFriendGroup.h"
12 #import "JWFriendHeaderView.h"
13 #import "JWFriendCell.h"
14 @interface ViewController () &JWFriendHeaderViewDelegate&
15 @property (nonatomic,strong) NSArray *friendG
18 @implementation ViewController
19 #pragma mark - 隐藏状态栏
20 - (BOOL)prefersStatusBarHidden {
return YES;
23 #pragma mark - 懒加载
24 - (NSArray *)friendGroup {
if (!_friendGroup) {
_friendGroup = [JWFriendGroup friendGroupList];
return _friendG
30 - (void)viewDidLoad {
[super viewDidLoad];
//设置组头的高度
self.tableView.sectionHeaderHeight = 44;
35 #pragma mark - tableViewDatasouce的方法
36 //显示多少组数据
37 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return self.friendGroup.
40 //每组数据显示多少行数据
41 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.friendGroup[section] isExpend ]?[self.friendGroup[section] friends].count : 0;//这里使用了三目运算符,主要是判断如果组头是展开的,那么显示行数据,否则显示为0
44 //显示每个cell的内容
45 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
JWFriendCell *cell = [JWFriendCell cellWithTableView:tableView];
cell.friendDatas = [self.friendGroup[indexPath.section] friends][indexPath.row];
50 #pragma mark - JWFriendHeaderView的方法
51 //显示组头view的内容
52 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
JWFriendHeaderView *headerView = [JWFriendHeaderView headerViewWithTableView:tableView];
headerView.friendGroup = self.friendGroup[section];
headerView.delegate =
headerView.tag =//把section赋值给组头的tag
return headerV
59 #pragma mark - JWFriendHeaderViewDelegate的方法
60 - (void)clickNameBtn:(JWFriendHeaderView *)headerView {
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:headerView.tag];
[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationNone];//判断点击的是哪个组头,然后加载对应的数据
阅读(...) 评论()}

我要回帖

更多关于 axure侧边栏展开收缩 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信