星空网 > 软件开发 > 操作系统

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类,内有归档持久化操作)

QQ空间/朋友圈类界面的搭建images/loading.gif' data-original="http://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif" >QQ空间/朋友圈类界面的搭建
 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

View Code

 

QQ空间/朋友圈类界面的搭建QQ空间/朋友圈类界面的搭建
 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

View Code

 

如下是frameModel的实现:

 

QQ空间/朋友圈类界面的搭建QQ空间/朋友圈类界面的搭建
 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

View Code

 

QQ空间/朋友圈类界面的搭建QQ空间/朋友圈类界面的搭建
 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   }else59     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 }

View Code

 

 tableviewcell的实现:

QQ空间/朋友圈类界面的搭建QQ空间/朋友圈类界面的搭建
 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 @end12 13 @interface SquareTableViewCell : UITableViewCell14 /**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

View Code
QQ空间/朋友圈类界面的搭建QQ空间/朋友圈类界面的搭建
 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   }else172     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     }else187       _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       }else193         [_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     else243       ((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

View Code

 

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

 




原标题:QQ空间/朋友圈类界面的搭建

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流