zoukankan      html  css  js  c++  java
  • 新浪微博客户端(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
  • 相关阅读:
    hdu 3666 差分约束系统
    hdu 1198农田灌溉
    常微分方程(阿諾爾德) Page 45 相空間,相流,運動,相曲線 註記
    高等微積分(高木貞治) 1.4節 例2
    常微分方程(阿諾爾德) Page 45 相空間,相流,運動,相曲線 註記
    解析函數論 Page 29 命題(2) 函數模的有界性
    高等微積分(高木貞治) 1.4節 例2
    解析函數論 Page 29 命題(1) 有界閉集上的一致連續性
    解析函數論 Page 29 命題(3) 模的下界的可達性
    解析函數論 Page 29 命題(2) 函數模的有界性
  • 原文地址:https://www.cnblogs.com/yongdaimi/p/6044690.html
Copyright © 2011-2022 走看看