Although you can drag the control directly in UITableView to add a cell, the fatal disadvantage of this method is that the cell is fixed and the height of the cell is difficult to change. In actual development, it cannot meet our needs. For example:
*text;@property (nonatomic,copy) NSString *icon;@property (nonatomic,copy) NSString *name;@property (nonatomic,copy) NSString *picture;@property (nonatomic,assign,getter = isVip) BOOL *vip;
- (instancetype) initWithDict: (NSDictionary *)dict;+ (instancetype) weiboWithDict: (NSDictionary *)dict;
The internal implementation of the method will not be described here!
The frame model is created to encapsulate the process of calculating the positions of various controls in the cell. This reflects the idea of OOP programming!
In the Frame model, the Frame of each control is calculated and set based on the passed data model. Therefore, the Frame model must have a data model attribute, the frame calculation process of each control should be placed in the set Method of the model data attribute, and the height of the cell is calculated here.
*
Has the member attribute of the frame model type, which is used to set frame and data for each control in the cell.
Because the frame model has a data model, you do not need to introduce the data model here.
@property (nonatomic, strong) CLWeiBoFrame *weiboFrame;
Besides, a class method is provided to call the cell creation interface and the tableView parameter must be input. The tableView parameter is passed in to obtain the cell queue loop in tableView.
+ (instancetype)cellWithTableView:(UITableView* NSString *ID = *cell = (cell ===
-()initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *
=
UIImageView *iconView =
=
UILabel *nameView =
=
=
UIImageView *vipView =
= [UIImage imageNamed:
=
UILabel *textView =
=
=
=
UIImageView *pictureView =
=
- () setCLWeiBoFrame:(MJStatusFrame *
=
*- (NSArray *
(_weiboframes ==
NSString *path = [[NSBundle mainBundle]pathForResource:
NSArray *dictArray =
NSMutableArray *weibosFrameArray =
(NSDictionary *dict
CLWeiBo *weibo =
CLWeiBoFrame *weiboFrame =
=
_weiboframes =
- (NSInteger)tableView:(UITableView *
- (UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*
MJStatusCell *cell =
cell.statusFrame =
4.3 proxy method implementation
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *
MJStatusFrame *statusFrame =
This is the end!