QQ空间/朋友圈类界面的搭建

类似于QQ空间的布局主要是在说说信息、点赞、回复三大部分的自适应布局上。

当我们需要搭建类似QQ空间、微信朋友圈的界面的时候,可做如下操作:

  1. 创建一个对应的model类;
  2. 创建一个对应model类的frameModel类,并将对应的model封装进这个frameModel类。frameModel类是将model对应显示的data的控件frame转换为一个可持久化的frame,这样一来,就可以在第3布容易很多;
  3. 创建一个talbleviewcell,根据 model可能显示的对象,初始化cell,并将frameModel封装进talbleviewcell。

我在这里写了一些测试的代码,大家可以参考一下。

如下是model的实现 (BasicModel 为我定义的basic类,内有归档持久化操作)

 1 #import "BasicModel.h"
 2
 3 @interface RadioModel : BasicModel<NSCopying>
 4 /**
 5  *  内容
 6  */
 7 @property(nonatomic, copy)NSString *msgContent;
 8 /**
 9  *  昵称
10  */
11 @property(nonatomic, copy)NSString *publisherNickName;
12 /**
13  *  头像
14  */
15 @property(nonatomic, copy)NSString *publisherImg;
16 /**
17  *  时间
18  */
19 @property(nonatomic, copy)NSString *publishTime;
20 /**
21  *  评论数组
22  */
23 @property(nonatomic, copy)NSMutableArray *commentsArray;
24 /**
25  *  点赞数组   (点赞者昵称)
26  */
27 @property(nonatomic, copy)NSMutableArray *thumbArray;
28
29
30 @end

 1 #import "RadioModel.h"
 2 #import <objc/runtime.h>
 3
 4 @implementation RadioModel
 5
 6 -(id)copyWithZone:(NSZone *)zone{
 7     RadioModel *model = [[RadioModel alloc] init];
 8
 9     u_int count;
10     objc_property_t *propertyList = class_copyPropertyList([self class], &count);
11
12     for (int index = 0; index < count; index++) {
13         objc_property_t property = propertyList[index];
14         NSString *str = [NSString stringWithUTF8String:property_getName(property)];
15
16         id value = [self valueForKey:str];
17         [model setValue:value forKey:str];
18     }
19
20     free(propertyList);
21
22     return model;
23 }
24
25 @end

如下是frameModel的实现:

 1 #import "BasicModel.h"
 2 //#import <Foundation/Foundation.h>
 3 //#import <UIKit/UIKit.h>
 4 #import "RadioModel.h"
 5
 6 @interface RadioModelFrame : BasicModel
 7 /**
 8  *  头像尺寸
 9  */
10 @property(nonatomic, copy)NSValue *iconFrameValue;
11 /**
12  *  昵称尺寸
13  */
14 @property(nonatomic, copy)NSValue *nickNameFrameValue;
15 /**
16  *  内容尺寸
17  */
18 @property(nonatomic, copy)NSValue *contentFrameValue;
19 /**
20  *  时间尺寸
21  */
22 @property(nonatomic, copy)NSValue *timeFrameValue;
23 /**
24  *  点赞按钮的尺寸
25  */
26 @property(nonatomic, copy)NSValue *thumbBtnFrameValue;
27 /**
28  *  评论按钮的尺寸
29  */
30 @property(nonatomic, copy)NSValue *commentBtnFrameValue;
31 /**
32  *  不包含赞、评论内容的高度
33  */
34 @property(nonatomic, copy)NSString *cellHeight;
35 /**
36  *  点赞人尺寸
37  */
38 @property(nonatomic, copy)NSValue *thumbPersonFrameValue;
39 /**
40  *  评论内容尺寸
41  */
42 //@property(nonatomic, assign)NSValue *commentsFrameValue;
43 /**
44  *  评论内容数据源
45  */
46 @property(nonatomic, strong)NSMutableArray *commentsArray;
47 /**
48  *  评论内容背景
49  */
50 @property(nonatomic, copy)NSValue *commentsBackGroundFrameValue;
51 /**
52  *  评论数据
53  */
54 @property(nonatomic, strong)RadioModel *radioModel;
55
56 @end

 1 #import "RadioModelFrame.h"
 2 #import "SCUtil.h"
 3 @implementation RadioModelFrame
 4
 5 -(void)setRadioModel:(RadioModel *)radioModel{
 6     _radioModel = radioModel;
 7
 8     float cellH;
 9
10     //头像
11     CGFloat iconX = WIDTHINIPHONE6(10);
12     CGFloat iconY = HEIGTHINIPHONE6(5);
13     CGFloat iconH = WIDTHINIPHONE6(60);
14     CGFloat iconW = WIDTHINIPHONE6(60);
15     self.iconFrameValue = [NSValue valueWithCGRect:CGRectMake(iconX, iconY, iconW, iconH)];
16
17     //昵称
18     CGFloat nickNameX = CGRectGetMaxX(CGRectMake(iconX, iconY, iconW, iconH)) + WIDTHINIPHONE6(5);
19     CGSize nickNameSize = [SCUtil sizeWithString:self.radioModel.publisherNickName font:HEADFONT size:CGSizeMake(SCREENWIDTH - WIDTHINIPHONE6(90), HEIGTHINIPHONE6(30))];
20     CGFloat nickNameY = iconY + HEIGTHINIPHONE6(20);
21     CGFloat nickNameW = nickNameSize.width;
22     CGFloat nickNameH = nickNameSize.height;
23     self.nickNameFrameValue = [NSValue valueWithCGRect:CGRectMake(nickNameX, nickNameY, nickNameW, nickNameH)];
24
25     //内容内容
26     CGFloat contentX = nickNameX;
27     CGFloat contentY = CGRectGetMaxY(CGRectMake(nickNameX, nickNameY, nickNameW, nickNameH)) + HEIGTHINIPHONE6(10);
28     CGSize contentSize = [SCUtil sizeWithString:self.radioModel.msgContent font:HEADFONT size:CGSizeMake(SCREENWIDTH- WIDTHINIPHONE6(80), 10000000)];
29     CGFloat contentW = contentSize.width;
30     CGFloat contentH = contentSize.height;
31     self.contentFrameValue = [NSValue valueWithCGRect:CGRectMake(contentX, contentY, contentW, contentH)];
32     cellH = contentH + HEIGTHINIPHONE6(60);
33
34     //时间显示
35     CGFloat timeX = nickNameX;
36     CGFloat timeY = cellH;
37     CGFloat timeW = WIDTHINIPHONE6(100);
38     CGFloat timeH = HEIGTHINIPHONE6(20);
39     self.timeFrameValue = [NSValue valueWithCGRect:CGRectMake(timeX, timeY, timeW, timeH)];
40
41     //评论、点赞按钮
42     CGFloat segY = cellH;
43     CGFloat segW = WIDTHINIPHONE6(30);
44     CGFloat segH = WIDTHINIPHONE6(30);
45     self.thumbBtnFrameValue = [NSValue valueWithCGRect:CGRectMake(SCREENWIDTH - WIDTHINIPHONE6(75), segY, segW, segH)];
46     self.commentBtnFrameValue = [NSValue valueWithCGRect:CGRectMake(SCREENWIDTH - WIDTHINIPHONE6(40), segY, segW, segH)];
47
48     cellH = CGRectGetMaxY(CGRectMake(SCREENWIDTH - WIDTHINIPHONE6(100), segY, segW, segH));
49
50     //点赞人显示
51     CGFloat thumX = nickNameX;
52     CGFloat thumY = cellH + HEIGTHINIPHONE6(0);
53     CGSize thumSize = [SCUtil sizeWithString:[_radioModel.thumbArray firstObject] font:FONT15TXT size:CGSizeMake((SCREENWIDTH - CGRectGetMinX([self.nickNameFrameValue CGRectValue]) - WIDTHINIPHONE6(30)), 10000000)];
54     CGFloat thumW = thumSize.width;
55     CGFloat thumH = thumSize.height;
56     if (thumSize.width > 1) {
57         thumW = thumSize.width + WIDTHINIPHONE6(20);
58     }else
59         thumH = 0.00f;
60
61     _thumbPersonFrameValue = [NSValue valueWithCGRect:CGRectMake(thumX, thumY, thumW, thumH)];
62     if (thumH != 0.0f) {
63         cellH += CGRectGetMaxY(CGRectMake(thumX, thumY, thumW, thumH));
64     }
65     //评论内容显示
66     CGFloat commentHeight = CGRectGetMaxY(CGRectMake(thumX, thumY, thumW, thumH)) + HEIGTHINIPHONE6(10);
67     if ([_radioModel.commentsArray count]) {
68         CGFloat commentX = nickNameX;
69         for (int i = 0; i < [self.radioModel.commentsArray count]; i++) {
70             NSDictionary *dictionry = [self.radioModel.commentsArray objectAtIndex:i];
71             NSString *commentName = [[dictionry objectForKey:@"CommentatorName"] stringByAppendingString:@":"];
72             NSString *commentContent = [dictionry objectForKey:@"CommentContent"];
73
74             CGSize commentSize = [SCUtil sizeWithString:[commentName stringByAppendingString:commentContent] font:FONT15TXT size:CGSizeMake(SCREENWIDTH - WIDTHINIPHONE6(100), 100000000)];
75             CGFloat commentY = commentHeight;
76             CGFloat commentW = commentSize.width + WIDTHINIPHONE6(10);
77             CGFloat commentH = commentSize.height;
78
79             cellH += commentH + HEIGTHINIPHONE6(2);
80             commentHeight += commentH + HEIGTHINIPHONE6(2);
81             CGRect segframe = CGRectMake(commentX, commentY, commentW, commentH);
82             [self.commentsArray addObject:[NSValue valueWithCGRect:segframe]];
83         }
84         cellH = CGRectGetMaxY([(NSValue *)[self.commentsArray lastObject] CGRectValue]) + HEIGTHINIPHONE6(10);
85         self.cellHeight = [NSString stringWithFormat:@"%.f",cellH];
86         CGFloat backGroundW = SCREENWIDTH - WIDTHINIPHONE6(90);
87         self.commentsBackGroundFrameValue = [NSValue valueWithCGRect:CGRectMake(nickNameX - WIDTHINIPHONE6(5), CGRectGetMaxY(CGRectMake(thumX, thumY, thumW, thumH)) + HEIGTHINIPHONE6(5), backGroundW + WIDTHINIPHONE6(10), commentHeight - CGRectGetMaxY(CGRectMake(thumX, thumY, thumW, thumH)))];
88     }else{
89         self.commentsBackGroundFrameValue = [NSValue valueWithCGRect:CGRectMake(nickNameX - WIDTHINIPHONE6(5), CGRectGetMaxY(CGRectMake(thumX, thumY, thumW, thumH)), 0, 0)];
90         self.cellHeight = [NSString stringWithFormat:@"%.f",CGRectGetMaxY(CGRectMake(thumX, thumY, thumW, thumH))];
91     }
92 }
93
94 -(NSMutableArray *)commentsArray{
95     if (!_commentsArray) {
96         _commentsArray = [[NSMutableArray alloc] init];
97     }
98     return _commentsArray;
99 }

tableviewcell的实现:

 1 #import <UIKit/UIKit.h>
 2 #import "RadioModelFrame.h"
 3
 4 @protocol addBtnActionDelegate <NSObject>
 5
 6
 7 -(void)supportAction:(RadioModelFrame *)frameModel;
 8
 9 -(void)sendMessage:(NSString *)message withModel:(RadioModelFrame *)frameModel;
10
11 @end
12
13 @interface SquareTableViewCell : UITableViewCell
14 /**
15  *  cell的视图尺寸类
16  */
17 @property(nonatomic, strong) RadioModelFrame *radioModelFrame;
18
19 +(instancetype)cellWithTableView:(UITableView *)tableView andRadioModel:(RadioModel *)model;
20
21 @property(nonatomic, weak)id<addBtnActionDelegate>delegate;
22
23 -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier andRadioModel:(RadioModel *)model;
24
25 @end

  1 #import "SquareTableViewCell.h"
  2 #import "RadioModel.h"
  3 #import "Masonry.h"
  4 #import "SCUtil.h"
  5
  6 @interface SquareTableViewCell ()<UITextFieldDelegate>
  7
  8 //@property(nonatomic, copy)RadioModel *radioModel;
  9
 10 @property(nonatomic, strong)NSMutableArray *thumbArray;
 11
 12 @property(nonatomic, strong)NSMutableArray *commentsViewArray;
 13
 14 @property(nonatomic, weak) UIImageView *iconImgView;
 15
 16 @property(nonatomic, weak) UILabel *nameLb;
 17
 18 @property(nonatomic, weak) UILabel *contentLb;
 19
 20 @property(nonatomic, weak) UILabel *timeLb;
 21 /**
 22  *  选择操作按钮(暂定“赞”、“评论”、“转发”三个选择)
 23  */
 24 @property(nonatomic, weak)UIButton *supportBtn;
 25
 26 @property(nonatomic, weak)UIButton *commentsBtn;
 27
 28 //@property(nonatomic, copy)UIButton *shareBtn;
 29 /**
 30  *  点赞人展示
 31  */
 32 @property(nonatomic, weak) UILabel *thumbPersonLb;
 33
 34 @property(nonatomic, weak) UIImageView *commentsBackGroundView;
 35 /**
 36  *  文本输入框
 37  */
 38 @property(nonatomic, weak) UITextField *textField;
 39
 40 @end
 41
 42 @implementation SquareTableViewCell
 43
 44 +(instancetype)cellWithTableView:(UITableView *)tableView andRadioModel:(RadioModel *)model
 45 {
 46     static NSString *identifier = @"RadioModelCell";
 47
 48     SquareTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
 49
 50     if (!cell) {
 51         cell = [[SquareTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier andRadioModel:model];
 52         cell.selectionStyle = UITableViewCellSelectionStyleNone;
 53     }
 54     return cell;
 55 }
 56
 57 -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier andRadioModel:(RadioModel *)model
 58 {
 59     self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
 60     if (self) {
 61         self.selectionStyle = UITableViewCellSelectionStyleNone;
 62         //头像
 63         UIImageView *imgView = [[UIImageView alloc] init];
 64         [imgView.layer setMasksToBounds:YES];
 65         [imgView.layer setCornerRadius:WIDTHINIPHONE6(30)];
 66         [self.contentView addSubview:imgView];
 67         self.iconImgView = imgView;
 68
 69         //昵称
 70         UILabel *nameLb = [[UILabel alloc] init];
 71         nameLb.font = HEADFONT;
 72         //nameLb.textColor = REDCOLOR;
 73         [self.contentView addSubview:nameLb];
 74         self.nameLb = nameLb;
 75
 76         //广播内容
 77         UILabel *radioLb = [[UILabel alloc] init];
 78         radioLb.font = HEADFONT;
 79         radioLb.numberOfLines = 0;
 80         [self.contentView addSubview:radioLb];
 81         self.contentLb = radioLb;
 82
 83         //时间显示
 84         UILabel *timeLb = [[UILabel alloc] init];
 85         timeLb.font = FONT12TXT;
 86         timeLb.textColor = GRAYBACK;
 87         [self.contentView addSubview:timeLb];
 88         self.timeLb = timeLb;
 89
 90         //点赞按钮
 91         UIButton *thumBtn = [UIButton buttonWithType:UIButtonTypeCustom];
 92         [thumBtn setImage:[UIImage imageNamed:@"thumb"] forState:UIControlStateNormal];
 93 //        [thumBtn setBackgroundColor:REDCOLOR];
 94         [thumBtn addTarget:self action:@selector(supportAction) forControlEvents:UIControlEventTouchUpInside];
 95         [self.contentView addSubview:thumBtn];
 96         _supportBtn = thumBtn;
 97
 98         //评论按钮
 99         UIButton *commentBtn = [UIButton buttonWithType:0];
100         [commentBtn setImage:[UIImage imageNamed:@"comment"] forState:0];
101 //        [commentBtn setBackgroundColor:[UIColor blueColor]];
102         [commentBtn addTarget:self action:@selector(commentToPerson) forControlEvents:UIControlEventTouchUpInside];
103         [self.contentView addSubview:commentBtn];
104         self.commentsBtn = commentBtn;
105
106         //点赞的所有人
107         UILabel *supportLb = [[UILabel alloc] init];
108         supportLb.textColor = [UIColor colorWithRed:251/255.f green:25/255.f blue:255/255.f alpha:1];
109         supportLb.font = FONT15TXT;
110         [self.contentView addSubview:supportLb];
111         self.thumbPersonLb = supportLb;
112
113         //评论的背景图
114         UIImageView *commentsBackImgView = [[UIImageView alloc] init];
115         commentsBackImgView.backgroundColor =  [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0];
116         [self.contentView addSubview:commentsBackImgView];
117         self.commentsBackGroundView = commentsBackImgView;
118
119         //输入框
120         UITextField *textfield = [[UITextField alloc] init];
121         textfield.delegate = self;
122         textfield.placeholder = @"评论";
123         textfield.borderStyle = UITextBorderStyleRoundedRect;
124         textfield.returnKeyType = UIReturnKeySend;
125         UIButton *clickBtn = [UIButton buttonWithType:UIButtonTypeCustom];
126         clickBtn.frame = CGRectMake(0, 0, WIDTHINIPHONE6(50), TABBARHEIGHT);
127         [clickBtn setBackgroundColor:DOMINANTCOLOR];
128         [clickBtn setTitle:@"发送" forState:UIControlStateNormal];
129         clickBtn.frame = CGRectMake(20, 20, WIDTHINIPHONE6(50), HEIGTHINIPHONE6(30));
130         [clickBtn addTarget:self action:@selector(sendComment) forControlEvents:UIControlEventTouchUpInside];
131         textfield.rightView = clickBtn;
132         textfield.rightViewMode = UITextFieldViewModeAlways;
133         [self.contentView addSubview:textfield];
134         self.textField = textfield;
135     }
136     return self;
137 }
138
139 -(void)setRadioModelFrame:(RadioModelFrame *)radioModelFrame{
140     _radioModelFrame = radioModelFrame;
141     [self removeOldComments];
142
143     [self settingData];
144
145     [self settingFrame];
146 }
147
148 //防止cell重叠
149 -(void)removeOldComments{
150     for (int i = 0; i < [self.commentsViewArray count]; i++) {
151         UILabel *commentsLb = [self.commentsViewArray objectAtIndex:i];
152         if (commentsLb.subviews) {
153             [commentsLb removeFromSuperview];
154         }
155     }
156     [self.commentsViewArray removeAllObjects];
157 }
158
159 -(void)settingData{
160     RadioModel *radio = self.radioModelFrame.radioModel;
161     //显示头像
162     [self.iconImgView sd_setImageWithURL:[NSURL URLWithString:(NSString *)radio.publisherImg] placeholderImage:[UIImage imageNamed:@"squareCell"]];
163     //显示昵称
164     if ([SCUtil checkTelNumber:radio.publisherNickName]) {
165         NSRange range1 = NSMakeRange(0, 3);
166         NSRange range2 = NSMakeRange(7, 4);
167         NSString *displayStr1 = [radio.publisherNickName substringWithRange:range1];
168         NSString *displayStr2 = [radio.publisherNickName substringWithRange:range2];
169         NSString *name = [[displayStr1 stringByAppendingString:@"***"] stringByAppendingString:displayStr2];
170         self.nameLb.text = name;
171     }else
172         self.nameLb.text = radio.publisherNickName;
173
174     //显示广播内容
175     self.contentLb.text = radio.msgContent;
176     //显示时间
177     self.timeLb.text = radio.publishTime;
178
179     User *user = [NSKeyedUnarchiver unarchiveObjectWithFile:LOGINCACHEPATH];
180     //点赞人 、点赞按钮
181     self.thumbPersonLb.textColor = REDCOLOR;
182     self.thumbPersonLb.numberOfLines = 0;
183     if ([radio.thumbArray count]) {  //显示点赞者
184         if (![SCUtil isBlankString:[radio.thumbArray firstObject]]) {
185             _thumbPersonLb.text = [@"?" stringByAppendingString:[radio.thumbArray firstObject]];
186         }else
187             _thumbPersonLb.text = @"";
188
189         if (![SCUtil isBlankString:user.nickName]) {
190             if ([_thumbPersonLb.text containsString:user.nickName]) {
191                 [_supportBtn setImage:[UIImage imageNamed:@"thumb2"] forState:UIControlStateNormal];
192             }else
193                 [_supportBtn setImage:[UIImage imageNamed:@"thumb"] forState:UIControlStateNormal];
194         }else{
195             [_supportBtn setImage:[UIImage imageNamed:@"thumb"] forState:UIControlStateNormal];
196         }
197     }else{
198         [_supportBtn setImage:[UIImage imageNamed:@"thumb"] forState:UIControlStateNormal];
199     }
200
201     //评论按钮
202         [self.commentsBtn setImage:[UIImage imageNamed:@"comment"] forState:UIControlStateNormal];
203
204     //显示评论
205     for (int i = 0; i < [radio.commentsArray count]; i++) {
206         UILabel *commentLb = [[UILabel alloc] init];
207         commentLb.font = FONT15TXT;
208         commentLb.numberOfLines = 0;
209
210         NSDictionary *dictionary = radio.commentsArray[i];
211         NSString *nameStr = [[dictionary objectForKey:@"CommentatorName"] stringByAppendingString:@":"];
212         NSString *contentStr = [dictionary objectForKey:@"CommentContent"];
213         NSString *string = [nameStr stringByAppendingString:contentStr];
214
215         NSMutableAttributedString *attriButeStr = [[NSMutableAttributedString alloc] initWithString:string];
216         [attriButeStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:251/255.f green:25/255.f blue:25/255.f alpha:1] range:NSMakeRange(0, nameStr.length)];
217
218         commentLb.attributedText = attriButeStr;
219         [self.contentView addSubview:commentLb];
220         [self.commentsViewArray addObject:commentLb];
221     }
222
223 }
224
225 -(void)settingFrame{
226     self.iconImgView.frame = [self.radioModelFrame.iconFrameValue CGRectValue];
227     self.nameLb.frame = [self.radioModelFrame.nickNameFrameValue CGRectValue];
228     self.contentLb.frame = [self.radioModelFrame.contentFrameValue CGRectValue];
229     self.timeLb.frame =[self.radioModelFrame.timeFrameValue CGRectValue];
230
231     //按钮
232     self.commentsBtn.frame =[self.radioModelFrame.commentBtnFrameValue CGRectValue];
233     self.supportBtn.frame = [self.radioModelFrame.thumbBtnFrameValue CGRectValue];
234
235     //点赞人字符串
236     self.thumbPersonLb.frame = [self.radioModelFrame.thumbPersonFrameValue CGRectValue];
237
238     for (int i = 0; i < [self.radioModelFrame.commentsArray count]; i++) {
239         if ([_commentsViewArray count] == 1) {
240             ((UILabel *)[_commentsViewArray objectAtIndex:0]).frame = [(NSValue *)[_radioModelFrame.commentsArray objectAtIndex:0] CGRectValue];
241         }
242         else
243             ((UILabel *)[_commentsViewArray objectAtIndex:i]).frame = [(NSValue *)[_radioModelFrame.commentsArray objectAtIndex:i] CGRectValue];
244     }
245
246     //评论的尺寸
247     self.commentsBackGroundView.frame = [self.radioModelFrame.commentsBackGroundFrameValue CGRectValue];
248
249     //文本
250     if (CGRectGetHeight(self.commentsBackGroundView.frame) > 1) {
251         self.textField.frame = CGRectMake(self.commentsBackGroundView.frame.origin.x, CGRectGetMaxY(self.commentsBackGroundView.frame) + HEIGTHINIPHONE6(5), self.commentsBackGroundView.frame.size.width, HEIGTHINIPHONE6(30));
252     }else if (CGRectGetHeight(self.thumbPersonLb.frame) > 1 ) {
253         self.textField.frame = CGRectMake(self.contentLb.frame.origin.x, CGRectGetMaxY(self.thumbPersonLb.frame) + HEIGTHINIPHONE6(5), SCREENWIDTH - WIDTHINIPHONE6(80), HEIGTHINIPHONE6(30));
254     }else{
255         self.textField.frame = CGRectMake(self.contentLb.frame.origin.x, CGRectGetMaxY(self.supportBtn.frame) + HEIGTHINIPHONE6(5), SCREENWIDTH - WIDTHINIPHONE6(80), HEIGTHINIPHONE6(30));
256     }
257
258 }
259
260 -(void)supportAction{
261     [self.delegate supportAction:_radioModelFrame];
262     [self.textField resignFirstResponder];
263 }
264
265 -(void)commentToPerson{
266     [self.textField becomeFirstResponder];
267 }
268
269 -(void)sendComment{
270     if (![SCUtil isBlankString:self.textField.text]) {
271         [self.delegate sendMessage:self.textField.text withModel:_radioModelFrame];
272         if (![SCUtil isBlankString:self.textField.text]) {
273             self.textField.text = @"";
274         }
275         [self.textField resignFirstResponder];
276     }
277 }
278
279 -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
280     if ([string isEqualToString:@"\n"]) {
281         if (![SCUtil isBlankString:self.textField.text]) {
282             [self.delegate sendMessage:self.textField.text withModel:_radioModelFrame];
283             if (![SCUtil isBlankString:self.textField.text]) {
284                 self.textField.text = @"";
285             }
286         }
287         [textField resignFirstResponder];
288         return NO;
289     }
290     return YES;
291 }
292
293 -(NSMutableArray *)commentsViewArray{
294     if (!_commentsViewArray) {
295         _commentsViewArray = [[NSMutableArray alloc] init];
296     }
297     return _commentsViewArray;
298 }
299
300 -(NSMutableArray *)thumbArray{
301     if (!_thumbArray) {
302         _thumbArray = [[NSMutableArray alloc] init];
303     }
304     return _thumbArray;
305 }
306
307 @end

一般按照上边的方法基本能够实现了要求,当然,我这里为方便并没有加入图片显示,方正步骤都类似,只是多加个参数而已。

时间: 2024-10-05 23:47:00

QQ空间/朋友圈类界面的搭建的相关文章

人人网,微博,QQ空间,朋友圈,常用API调用实现方法

<div class="bdsharebuttonbox"> <span>分享至:</span><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title=&q

h5怎么做分享到QQ 、朋友圈、微信 、微博等功能

微信已经成为我们日常聊天联系基本的必备工具,所以小菜我首先介绍一下如何调用微信的分享功能.其实除了可以在微信上分享到朋友圈和发送给好友,微信的分享接口还提供了分享到QQ和分享到腾讯微博等,就是在页面的config接口注入权限验证配置好就ok! 类似于"分享到朋友圈"按钮点击状态及自定义分享内容接口,我们调用"分享到QQ"和"分享到腾讯微博"按钮点击状态及自定义分享内容接口 . 获取"分享到QQ"按钮点击状态及自定义分享内容接口

微信朋友圈怎么转发?

使用微信的朋友们最喜欢干的一件事就是刷朋友圈,朋友圈上有各种晒美食,美景,心灵鸡汤,搞笑娱乐类型的段子,有时候看到喜欢的内容,难免会想转发到自己的朋友圈,让自己的朋友也看看,可是找了半天,也没看到微信朋友圈的转发在哪里,只有评论和点赞功能,如果你想知道微信朋友圈怎么转发,就跟着系统圣地小编一起来看看本文微信如何转发别人的朋友圈教程. 微信朋友圈怎么转发 首先大家要知道的一件事:微信朋友圈并不能像qq那样直接转发走,只能先把好友的图片保存到手机,然后把内容复制下来,再到自己的朋友圈点相机发表,其实

andriod 实现新浪、QQ空间、微信朋友圈、微信好友分享功能

前言:自己在学习的过程中的一些操作过程,对分享的一些理解.下面就讲解一下: 下载地址:http://download.csdn.net/detail/u014608640/7490357 首先,我们需要去ShareSdk官方网站http://sharesdk.cn/ 去下载ShareSDK ,然后我们会有4个文件: 根据我自己在学习的过程中只用到了第一个文件夹的 libs目录的2个项目,这2个是必须要的,是ShareSdk提供的,然后需要将这2个放入到自己做的项目当中去,在Res目录下有一个 S

Android:NineGridLayout — 仿微信朋友圈和QQ空间的九宫格图片展示自定义控件

NineGridLayout 一个仿微信朋友圈和QQ空间的九宫格图片展示自定义控件. GitHub:https://github.com/HMY314/NineGridLayout 一.介绍 1.当只有1张图时,可以自己定制图片宽高,也可以使用默认九宫格的宽高: 2.当只有4张图时,以2*2的方式显示: 3.除以上两种情况下,都是按照3列方式显示,但这时有一些细节: a.如果只有9张图,当然是以3*3的方式显示: b.如果超过9张图,可以设置是否全部显示. 如果设置不完全显示,则按照3*3的方式

android接入微信分享(朋友、朋友圈)、QQ分享(好友、空间)

1.申请注册你的appid 2.下载sdk QQ: http://wiki.open.qq.com/wiki/mobile/SDK%E4%B8%8B%E8%BD%BD 微信:https://open.weixin.qq.com/cgi-bin/readtemplate?t=resource/app_download_android_tmpl&lang=zh_CN 3.将下载的文件 导入进工程下的app/libs/下,liba开头的的微信需要的,另外两个是QQ需要的 阅读官方文档QQ:http:/

asp.net mvc 如何调用微信jssdk接口:分享到微信朋友(圈)| 分享到qq空间

如何在asp.net mvc 项目里, 调用微信jssdk接口,现实功能: 分享到微信朋友(圈)| 分享到qq空间 1 创建一个Action,准备一些数据,初始化数据(签名): /// <summary> /// 分享的内容 /// 必须写在html的head里面才可以生效 /// </summary> /// <param name="fxUrl"></param> /// <returns></returns>

IOS开发--iPad之QQ空间 :(一)搭建登录界面

登录界面效果图: 相关的图片资源下载百度云备份链接: http://pan.baidu.com/s/1o71cvMU 密码: 2h7e 步骤开始: 设置辅助窗口的位置在下方 快捷键option,然后拖拽复制之后: 这里就直接省去了将背景颜色改为经典黑了. 到这里QQ空间的登录界面搭建完毕.

Android 调用系统分享文字、图片、文件,可直达微信、朋友圈、QQ、QQ空间、微博

原文:Android 调用系统分享文字.图片.文件,可直达微信.朋友圈.QQ.QQ空间.微博 兼容SDK 18以上的系统,直接调用系统分享功能,分享文本.图片.文件到第三方APP,如:微信.QQ.微博等 因为偷懒,可直达微信.朋友圈.QQ.QQ空间.微博的分享仅写了图片分享的,其他的文本.文件分享不常用到,就不写了. 具体图片分享区分单张图片分享和多张图片分享,详情请看代码: import android.content.ComponentName; import android.content