新浪微博客户端(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, ...
- [CareerCup] 5.2 Binary Representation of Real Number 实数的二进制表示
5.2 Given a real number between 0 and 1 (e.g., 0.72) that is passed in as a double, print the binary ...
- Linux 读书笔记 一
一.Linux 简介 实验介绍 本节主要介绍 Linux 的历史,Linux 与 Windows 的区别等入门知识.如果你已经有过充分的了解,可以跳过本节,直接进入下一个实验. 一.Linux 为何物 ...
- GDB深入研究——20135308芦畅
GDB深入研究 一.GDB代码调试 (一)GDB调试实例 在终端中编译一个示例C语言小程序,保存到文件 gdb-sample.c 中,用GCC编译之 #include <stdio.h> ...
- 利用Gulp优化部署Web项目[长文慎入]
Gulp Gulp是一款项目自动化的构建工具,与Grunt一样可以通过创建任务(Task)来帮助我们自动完成一些工作流的内容.当然,今天我们的内容并不是讨论这二者的区别,仅仅是介绍介绍如何利用Gulp ...
- 使用IDEA进行代码托管
在idea菜单栏的file中打开settings/搜索git,配置path to Git executable:C:\Program Files\Git\bin\git.exe(git bash的安装 ...
- 类似IOS的滑动返回上一级,SwipeBackLayout-android的滑动返回类库
最近,公司在开发App的需求中增加了一个新的需求,要在android的页面中增加向右滑动的时候返回上一级页面.我刚知道这个需求的时候,感觉有点坑,可能设计那边最近接触到知乎的客户端或者是IOS的滑动可 ...
- requirejs的基本学习
1.首先看几个简单的学习网站. http://www.runoob.com/w3cnote/requirejs-tutorial-1.html 这里边有两个教程一个一,一个二,看完后你有简单的了解.
- AaronYang的C#私房菜[二][提供编程效率的技巧]
前言 我的文章简单易懂,能学到东西.因为复杂的东西,讲起来,好累.阅读者只是膜拜,学不到东西,就是没用的东西,好多文章都是看不下去.我写不出来<大话设计模式>那种为了读者的书,因为没有时间 ...
- VS插件之小番茄
文件源以及安装说明! http://www.youranshare.com/app/98.html