iOS TableView实现QQ好友列表(二)
2015-06-18 18:58
489 查看
上节:iOS TableView实现QQ好友列表(一)
http://blog.csdn.net/lwjok2007/article/details/46534123
上一节实现了简单的好友列表,但是信息不够丰富,本节将好友的头像,名称,签名等信息全部显示出来
此处我们需要自定义cell
创建一个类 继承
UITableViewCell
添加所需属性
重写初始化方法 添加各属性
修改viewcontroller 中tablevew的delegate方法
将其中cell修改成自定义的cell 这样就能按照自己想要的样式去实现
此时完成了好友信息的基本展示
下节我们讲继续讲一下如何讲分组折叠起来
如果有问题可加qq讨论
苹果开发群 :414319235 欢迎加入
源代码将在群共享发布
http://blog.csdn.net/lwjok2007/article/details/46534123
上一节实现了简单的好友列表,但是信息不够丰富,本节将好友的头像,名称,签名等信息全部显示出来
此处我们需要自定义cell
创建一个类 继承
UITableViewCell
添加所需属性
#import <UIKit/UIKit.h> @interface UserTableViewCell : UITableViewCell @property (strong,nonatomic) UIImageView *headerphoto;//头像 @property (strong,nonatomic) UILabel *nameLabel;//昵称 @property (strong,nonatomic) UILabel *isOnLine;//是否在线 @property (strong,nonatomic) UILabel *introductionLabel;//个性签名,动态等 @property (strong,nonatomic) UILabel *networkLabel;//网络状态 @end
重写初始化方法 添加各属性
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { headerphoto=[[UIImageView alloc]initWithFrame:CGRectMake(10, 5, 50, 50)]; [self.contentView addSubview:headerphoto]; nameLabel=[[UILabel alloc]initWithFrame:CGRectMake(60, 5, 200, 25)]; nameLabel.backgroundColor=[UIColor clearColor]; nameLabel.font=[UIFont systemFontOfSize:16]; [self.contentView addSubview:nameLabel]; isOnLine=[[UILabel alloc]initWithFrame:CGRectMake(60, 40, 50, 5)]; isOnLine.font=[UIFont systemFontOfSize:10]; [self.contentView addSubview:isOnLine]; introductionLabel=[[UILabel alloc]initWithFrame:CGRectMake(120, 40, 180, 5)]; introductionLabel.font=[UIFont systemFontOfSize:10]; [self.contentView addSubview:introductionLabel]; networkLabel=[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-50, 5, 50, 25)]; networkLabel.font=[UIFont systemFontOfSize:10]; [self.contentView addSubview:networkLabel]; } return self; }
修改viewcontroller 中tablevew的delegate方法
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *str=[titleArray objectAtIndex:indexPath.section]; NSArray *arr=[dataDic objectForKey:str]; static NSString *CellIdentifier = @"UserCell"; UserTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; cell=nil; if (cell == nil) { cell = [[UserTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.selectionStyle = UITableViewCellSelectionStyleGray; } NSDictionary *dic=[arr objectAtIndex:indexPath.row]; cell.headerphoto.image=[UIImage imageNamed:[dic valueForKey:@"usericon"]]; cell.nameLabel.text=[dic valueForKey:@"name"]; cell.isOnLine.text=@"[在线]"; cell.introductionLabel.text=@"无动态"; cell.networkLabel.text=@"4G"; return cell; }
将其中cell修改成自定义的cell 这样就能按照自己想要的样式去实现
此时完成了好友信息的基本展示
下节我们讲继续讲一下如何讲分组折叠起来
如果有问题可加qq讨论
苹果开发群 :414319235 欢迎加入
源代码将在群共享发布
相关文章推荐
- OC基础:数组.字典.集 分类: ios学习 OC 2015-06-18 18:58 47人阅读 评论(0) 收藏
- 01.ios之路-ready go!
- ios内存管理原则
- iOS本地推送
- 10步成为专业iOS开发者——从零起步
- iOS开发——keychain的使用
- IOS ARC 机制
- 后台识别iOS设备为computer
- iOS图形库CorePlot
- iOS 模拟器小技巧
- ios证书相关
- IOS中nil、Null、Nil和NSNull的区别
- 连载五 奖学金文章更新 张文军 北京IOS第38期学员
- iOS 中划线
- [IOS]调用手机邮件系统发送邮件
- IOS弱网测试
- iOS沙盒机制,文件操作
- ios_常用关键字
- iOS问题
- 网易新闻iOS版在开发过程中曾经使用过的第三方开源类库、组件