新浪微博客户端(22)-创建微博Cell
DJStatusCell.h
#import <UIKit/UIKit.h> @class DJStatusCellFrame;
@interface DJStatusCell : UITableViewCell /** DJStatusCell 的默认构造方法 */
+ (instancetype)cellWithTableView:(UITableView *)tableView; @property (nonatomic,strong) DJStatusCellFrame *statusFrame; @end
DJStatusCell.m
#import "DJStatusCell.h"
#import "DJStatusCellFrame.h"
#import "DJStatus.h"
#import "DJUser.h"
#import "UIImageView+WebCache.h" @interface DJStatusCell() //============================== 原创微博部分 ======================================== /** 原创微博整体 */
@property (nonatomic,weak) UIView *originalView;
/** 头像 */
@property (nonatomic,weak) UIImageView *iconView;
/** 会员标志 */
@property (nonatomic,weak) UIImageView *vipView;
/** 微博图片 */
@property (nonatomic,weak) UIImageView *photoView;
/** 昵称 */
@property (nonatomic,weak) UILabel *nameLabel;
/** 发布时间 */
@property (nonatomic,weak) UILabel *timeLabel;
/** 微博来源 */
@property (nonatomic,weak) UILabel *sourceLabel;
/** 微博内容 */
@property (nonatomic,weak) UILabel *contentLabel; //============================== 原创微博部分 ======================================== @end @implementation DJStatusCell + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *ID = @"status"; DJStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
if (!cell) {
cell = [[DJStatusCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
}
return cell;
} /** cell的默认初始化方法,此方法只会被调用一次 */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) { // 原创微博整体
UIView *originalView = [[UIView alloc] init];
[self.contentView addSubview:originalView];
self.originalView = originalView; // 头像
UIImageView *iconView = [[UIImageView alloc] init];
[self.originalView addSubview:iconView];
self.iconView = iconView; // 会员标志
UIImageView *vipView = [[UIImageView alloc] init];
[self.originalView addSubview:vipView];
self.vipView = vipView; // 微博图片
UIImageView *photoView = [[UIImageView alloc] init];
[self.originalView addSubview:photoView];
self.photoView = photoView; // 昵称
UILabel *nameLabel = [[UILabel alloc] init];
[self.originalView addSubview:nameLabel];
self.nameLabel = nameLabel; // 发布时间
UILabel *timeLabel = [[UILabel alloc] init];
[self.originalView addSubview:timeLabel];
self.timeLabel = timeLabel; // 微博来源
UILabel *sourceLabel = [[UILabel alloc] init];
[self.originalView addSubview:sourceLabel];
self.sourceLabel = sourceLabel; // 微博内容
UILabel *contentLabel = [[UILabel alloc] init];
[self.originalView addSubview:contentLabel];
self.contentLabel = contentLabel; }
return self; } - (void)setStatusFrame:(DJStatusCellFrame *)statusFrame { _statusFrame = statusFrame; DJStatus *status = statusFrame.status;
DJUser *user = status.user; /* 设置当前View的Frame */ // 原创微博整体
self.originalView.frame = statusFrame.originalViewF; // 头像
self.iconView.frame = statusFrame.iconViewF;
[self.iconView sd_setImageWithURL:[NSURL URLWithString:user.profile_image_url] placeholderImage:[UIImage imageNamed:@"avatar_default_small"]]; // 会员标志
self.vipView.frame = statusFrame.vipViewF;
[self.vipView setImage:[UIImage imageNamed:@"common_icon_membership_level1"]]; // 微博图片
self.photoView.frame = statusFrame.photoViewF; // 昵称
self.nameLabel.frame = statusFrame.nameLabelF;
self.nameLabel.text = user.name; // 发布时间
self.timeLabel.frame = statusFrame.timeLabelF; // 微博来源
self.sourceLabel.frame = statusFrame.sourceLabelF; // 微博内容
self.contentLabel.frame = statusFrame.contentLabelF;
self.contentLabel.text = status.text; } @end
DJStatusCellFrame.h
#import <Foundation/Foundation.h> @class DJStatus;
@interface DJStatusCellFrame : NSObject /** 微博数据实体 */
@property (nonatomic,strong) DJStatus *status; /** 原创微博整体的Frame */
@property (nonatomic,assign) CGRect originalViewF;
/** 头像的Frame */
@property (nonatomic,assign) CGRect iconViewF;
/** 会员标志的Frame */
@property (nonatomic,assign) CGRect vipViewF;
/** 微博图片的Frame */
@property (nonatomic,assign) CGRect photoViewF;
/** 昵称的Frame */
@property (nonatomic,assign) CGRect nameLabelF;
/** 发布时间的Frame */
@property (nonatomic,assign) CGRect timeLabelF;
/** 微博来源的Frame */
@property (nonatomic,assign) CGRect sourceLabelF;
/** 微博内容的Frame */
@property (nonatomic,assign) CGRect contentLabelF; /** 当前微博的高度 */
@property (nonatomic,assign) CGFloat cellHeight; @end
DJStatusCellFrame.m
#import "DJStatusCellFrame.h"
@implementation DJStatusCellFrame
- (void)setStatus:(DJStatus *)status {
_status = status;
}
@end
新浪微博客户端(22)-创建微博Cell的更多相关文章
- 新浪微博客户端开发之OAuth认证篇
新浪微博客户端开发之OAuth认证篇 2013年7月29日新浪微博客户端开发 OAuth2.0授权机制我在这里就不浪费口舌了,有很多大牛都发表过相关的文章解释OAuth2.0认证的流程,我就随便找了一 ...
- android开发新浪微博客户端 完整攻略 [新手必读]
开始接触学习android已经有3个礼拜了,一直都是对着android的sdk文档写Tutorials从Hello World到Notepad Tutorial算是初步入门了吧,刚好最近对微博感兴趣就 ...
- Aisen仿新浪微博客户端项目源码
新浪目前已经限制了第三方微博的很多API接口,加上平常时间不够,所以后续可能不会面向产品的去维护Aisen,不过也有了一些新的方向,例如引入最新Android-support-library,在一个完 ...
- [iOS微博项目 - 4.0] - 自定义微博cell
github: https://github.com/hellovoidworld/HVWWeibo A.自定义微博cell基本结构 1.需求 创建自定义cell的雏形 cell包含:内容.工具条 内 ...
- Android应用--新浪微博客户端新特性滚动视图和启动界面实现
新浪微博客户端新特性滚动视图和启动界面实现 2013年8月20日新浪微博客户端开发之启动界面实现 前言: 使用过新浪微博客户端的童鞋都清楚,客户端每一次升级之后第一次启动界面就会有新特性的介绍,用户通 ...
- android 新浪微博客户端的表情功能的实现
这是一篇好文章,我转来收藏,技术的最高境界是分享. 最近在搞android 新浪微博客户端,有一些心得分享弄android客户端表情功能可以用以下思路1.首页把新浪的表情下载到本地一文件夹种,表情图片 ...
- 使用electron开发一个h5的客户端应用创建http服务模拟后台接口mock
使用electron开发一个h5的客户端应用创建http服务模拟后端接口mock 在上一篇<electron快速开始>里讲述了如何快速的开始一个electron的应用程序,既然electr ...
- NIO客户端主要创建过程
NIO客户端主要创建过程: 步骤一:打开SocketChannel,绑定客户端本地地址(可选,默认系统会随机分配一个可用的本地地址),示例代码如下: SocketChannel client ...
- 四次元新浪微博客户端Android源码
四次元新浪微博客户端Android源码 源码下载:http://code.662p.com/list/11_1.html [/td][td] [/td][td] [/td][td] 详细说明:http ...
随机推荐
- Matlab中的fread函数
Matlab中fread函数用法 "fread"以二进制形式,从文件读出数据. 语法1:[a,count]=fread(fid,size,precision) 语法2:[a, ...
- Linux下目录的合并以及文件的覆盖
有两个目录test和new,test目录下有目录和文件,new目录下有更改过的一些test下的目录和文件,以及一些新增的文件,现在对两个目录进行合并以及覆盖test下的旧文件. cp -frap ne ...
- Activiti系列: 如何给内置表单添加字段类型
对于内置的表单,除了原来支持的几种数据类型(string, long, enum, date, boolean, collection)之外,还可以自定义数据类型,比如增加一个javascript数 ...
- 实验一(不知道怎么上传.docx格式)
北京电子科技学院(BESTI) 实 验 报 告 课程:深入理解计算机系统 班级:1353 姓名:魏静静 文艺 刘虹辰 学号:20135302 20135331 20 ...
- 20145215实验五 Java网络编程及安全
20145215实验五 Java网络编程及安全 实验内容 掌握Socket程序的编写: 掌握密码技术的使用: 设计安全传输系统. 实验步骤 本次实验我的结对编程对象是20145208蔡野,我负责编写客 ...
- grootJs的vm结构
按看这段代码生成的vm groot.view("myview", function (vm, ve) { vm.say = "hello word!"; }) ...
- 免费的SSL证书,免费为微信小程序搭建https
StartSSL 也免费提供了一个证书(纯英文) 申请地址:https://www.startssl.com/Account?r=L1ZhbGlkYXRl 阿里云免费提供的证书 https://com ...
- Visual Studio命令窗口
命令”窗口用于直接在 Visual Studio 集成开发环境 (IDE) 中执行命令或别名.可以执行菜单命令和不在任何菜单上显示的命令.若要显示“命令”窗口,请从“视图”菜单中选择“其他窗口”,再选 ...
- redis学习笔记——(2)
4.Redis中的string类型 String类型是最简单的类型,一个Key对应一个Value,String类型是二进制安全的.Redis的String可以包含任何数据,比如jpg图片或者序列化的对 ...
- 年前辞职-WCF入门学习(1,2)
前言 周一的时候辞职了,离开了从12年毕业后8月份开始一直到现在的公司. 辞职之后当然是玩.玩了若干天的游戏,真的是没日没夜啊,但是玩的太坑,怒删游戏.话说上次玩还是在14年7月份.下次还是过年回家再 ...