Commit fabe44c52a39e3cc2eccbb1517ce29dccf44b81b
1 parent
aa09b669
评论
Showing
12 changed files
with
358 additions
and
17 deletions
LiveVideoCloud/AppDelegate/AppDelegate.m
| ... | ... | @@ -28,12 +28,15 @@ |
| 28 | 28 | //APP 启动是初始化直播SDK |
| 29 | 29 | [[CNLiveWebcastManager manager] initWithAppId:UserAppId appKey:UserAppKey isTestEnvironment:self.isTestEnvironment]; |
| 30 | 30 | |
| 31 | - //初始化聊天SDK并连接服务器 | |
| 32 | - [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:UserAppKey appId:UserAppId isTestEnvironment:self.isTestEnvironment]; | |
| 31 | + // 初始化评论功能 | |
| 32 | + [[CNLiveCommentManager sharedCNLiveCommentManager] registerWithAppId:@"60_irn9cdak77" appKey:@"a425987ebc86e352b3373c25d5bd082d0cc248b4043028" isTestEnvironment:YES]; | |
| 33 | 33 | |
| 34 | 34 | //初始化用户SDK |
| 35 | 35 | [CNLiveUserSystemCenter setAppId:UserAppId appKey:UserAppKey appSecret:UserAppSceret isTestEnvironment:self.isTestEnvironment]; |
| 36 | 36 | |
| 37 | + //初始化聊天SDK并连接服务器 | |
| 38 | + [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:UserAppKey appId:UserAppId isTestEnvironment:self.isTestEnvironment]; | |
| 39 | + | |
| 37 | 40 | /* |
| 38 | 41 | [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{ |
| 39 | 42 | NSLog(@"连接服务器-----success"); | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerController.m
| ... | ... | @@ -591,16 +591,19 @@ typedef enum { |
| 591 | 591 | |
| 592 | 592 | switch (_player.playbackState) { |
| 593 | 593 | case MPMoviePlaybackStateStopped: { |
| 594 | + _isPlaying = NO; | |
| 594 | 595 | [self changePlayBtnStatus:NO]; |
| 595 | 596 | NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateStopped"); |
| 596 | 597 | break; |
| 597 | 598 | } |
| 598 | 599 | case MPMoviePlaybackStatePlaying: { |
| 600 | + _isPlaying = YES; | |
| 599 | 601 | [self changePlayBtnStatus:YES]; |
| 600 | 602 | NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePlaying"); |
| 601 | 603 | break; |
| 602 | 604 | } |
| 603 | 605 | case MPMoviePlaybackStatePaused: |
| 606 | + _isPlaying = NO; | |
| 604 | 607 | [self changePlayBtnStatus:NO]; |
| 605 | 608 | NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePaused"); |
| 606 | 609 | break; | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerListController.m
| ... | ... | @@ -67,7 +67,7 @@ static NSString *vodCellId = @"vodCellId"; |
| 67 | 67 | for (NSDictionary *dic in responseObject[@"programs"]) { |
| 68 | 68 | ProgramModel *programModel = [ProgramModel modelWithDic:dic]; |
| 69 | 69 | [_programArrayM addObject:programModel]; |
| 70 | - if (dic[@"comments"] && [dic[@"comments"] isKindOfClass:[NSArray class]] && [dic[@"comments"] count] > 0) { | |
| 70 | + if (dic[@"comments"] && [dic[@"comments"] isKindOfClass:[NSArray class]] && [(NSArray *)dic[@"comments"] count] > 0) { | |
| 71 | 71 | NSMutableArray *comments = [[NSMutableArray alloc] init]; |
| 72 | 72 | for (NSDictionary *commentDic in dic[@"comments"]) { |
| 73 | 73 | LVCCommentModel *commentModel = [LVCCommentModel modelWithDic:commentDic]; | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/View/LVCCommentCell.h
LiveVideoCloud/Classes/Sections/homeSections/View/LVCCommentCell.m
| ... | ... | @@ -23,12 +23,49 @@ |
| 23 | 23 | { |
| 24 | 24 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; |
| 25 | 25 | if (self) { |
| 26 | + [self addSubview:self.iconView]; | |
| 26 | 27 | [self addSubview:self.nameLabel]; |
| 28 | + [self addSubview:self.likeButton]; | |
| 27 | 29 | [self addSubview:self.commentLabel]; |
| 28 | 30 | } |
| 29 | 31 | return self; |
| 30 | 32 | } |
| 31 | 33 | |
| 34 | +- (void)setResult:(CNLiveCommentDetailInfoResult *)result { | |
| 35 | + | |
| 36 | + _result = result; | |
| 37 | + [_iconView sd_setImageWithURL:[NSURL URLWithString:result.facepath] placeholderImage:[UIImage imageNamed:@"load_03"]]; | |
| 38 | + if (result.nick) { | |
| 39 | + _nameLabel.text = result.nick; | |
| 40 | + } else { | |
| 41 | + _nameLabel.text = @"游客"; | |
| 42 | + } | |
| 43 | + _commentLabel.text = result.content; | |
| 44 | + [_commentLabel sizeToFit]; | |
| 45 | + [_likeButton setTitle:result.praise forState:UIControlStateNormal]; | |
| 46 | + [_likeButton setImageEdgeInsets:UIEdgeInsetsMake(12, 5, 12, 35)]; | |
| 47 | + [_likeButton setTitleEdgeInsets:UIEdgeInsetsMake(0, -60, 0, 0)]; | |
| 48 | +} | |
| 49 | + | |
| 50 | +#pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 51 | +- (void)praiseAction:(UIButton *)btn { | |
| 52 | + | |
| 53 | + [[CNLiveCommentManager sharedCNLiveCommentManager] commentaryLikeWithProgramId:_result.pid sid:_result.uid commentId:_result.commentId completion:^(NSString *errorCode, NSString *errorMsg) { | |
| 54 | + | |
| 55 | + if ([errorCode isEqualToString:@"0"]) { | |
| 56 | + | |
| 57 | + NSLog(@"success"); | |
| 58 | + btn.selected = YES; | |
| 59 | + [btn setUserInteractionEnabled:NO]; | |
| 60 | + _result.praise = [NSString stringWithFormat:@"%ld",[_result.praise integerValue] + 1]; | |
| 61 | + [_likeButton setTitle:_result.praise forState:UIControlStateNormal]; | |
| 62 | + | |
| 63 | + } else { | |
| 64 | + NSLog(@"failed"); | |
| 65 | + } | |
| 66 | + }]; | |
| 67 | +} | |
| 68 | + | |
| 32 | 69 | #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 33 | 70 | - (UIImageView *)iconView { |
| 34 | 71 | if (!_iconView) { |
| ... | ... | @@ -39,7 +76,8 @@ |
| 39 | 76 | |
| 40 | 77 | - (UILabel *)nameLabel { |
| 41 | 78 | if (!_nameLabel) { |
| 42 | - _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 10, KScreenWidth-130, 30)]; | |
| 79 | + _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 10, KScreenWidth-120, 30)]; | |
| 80 | + _nameLabel.textColor = [UIColor grayColorCNLive]; | |
| 43 | 81 | } |
| 44 | 82 | return _nameLabel; |
| 45 | 83 | } |
| ... | ... | @@ -51,13 +89,22 @@ |
| 51 | 89 | [_likeButton setImage:[UIImage imageNamed:@"videoSupportNormal"] forState:UIControlStateNormal]; |
| 52 | 90 | [_likeButton setImage:[UIImage imageNamed:@"videoSupport"] forState:UIControlStateSelected]; |
| 53 | 91 | _likeButton.titleLabel.font = [UIFont systemFontOfSize:12]; |
| 54 | - [_likeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | |
| 92 | + [_likeButton setTitleColor:[UIColor grayColorCNLive] forState:UIControlStateNormal]; | |
| 55 | 93 | _likeButton.backgroundColor = [UIColor whiteColor]; |
| 56 | 94 | [_likeButton addTarget:self action:@selector(praiseAction:) forControlEvents:UIControlEventTouchUpInside]; |
| 57 | 95 | } |
| 58 | 96 | return _likeButton; |
| 59 | 97 | } |
| 60 | 98 | |
| 99 | +- (UILabel *)commentLabel { | |
| 100 | + if (!_commentLabel) { | |
| 101 | + _commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 55, KScreenWidth-20, 10)]; | |
| 102 | + _commentLabel.textColor = [UIColor grayColorCNLive]; | |
| 103 | + _commentLabel.font = [UIFont systemFontOfSize:14]; | |
| 104 | + } | |
| 105 | + return _commentLabel; | |
| 106 | +} | |
| 107 | + | |
| 61 | 108 | - (void)awakeFromNib { |
| 62 | 109 | [super awakeFromNib]; |
| 63 | 110 | // Initialization code | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/View/LVCCommentTitleCell.m
| ... | ... | @@ -40,7 +40,6 @@ |
| 40 | 40 | |
| 41 | 41 | if (!_titleLabel) { |
| 42 | 42 | _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, KScreenWidth-20, 40)]; |
| 43 | - [_contentLabel setFont:[UIFont systemFontOfSize:22]]; | |
| 44 | 43 | _titleLabel.text = @"标题"; |
| 45 | 44 | } |
| 46 | 45 | return _titleLabel; |
| ... | ... | @@ -49,7 +48,7 @@ |
| 49 | 48 | - (UILabel *)contentLabel { |
| 50 | 49 | |
| 51 | 50 | if (!_contentLabel) { |
| 52 | - _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, KScreenWidth-20, 100)]; | |
| 51 | + _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, KScreenWidth-20, 10)]; | |
| 53 | 52 | [_contentLabel setFont:[UIFont systemFontOfSize:14]]; |
| 54 | 53 | _contentLabel.textColor = [UIColor grayColor]; |
| 55 | 54 | _contentLabel.text = @"描述"; | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/View/LVCCommentView.m
| ... | ... | @@ -8,12 +8,24 @@ |
| 8 | 8 | |
| 9 | 9 | #import "LVCCommentView.h" |
| 10 | 10 | #import "LVCCommentTitleCell.h" |
| 11 | +#import "LVCCommentCell.h" | |
| 11 | 12 | |
| 12 | 13 | static NSString *titleCellId = @"titleCellId"; |
| 14 | +static NSString *commentCellId = @"commentCellId"; | |
| 13 | 15 | |
| 14 | -@interface LVCCommentView()<UITableViewDelegate, UITableViewDataSource> | |
| 16 | +@interface LVCCommentView()<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate> { | |
| 17 | + | |
| 18 | + NSArray *_commentArray; | |
| 19 | + CGFloat _desHeight; | |
| 20 | + NSMutableArray *_cellHeightArrayM; | |
| 21 | +} | |
| 15 | 22 | |
| 16 | 23 | @property (nonatomic, strong) UITableView *tableview; |
| 24 | +@property (nonatomic, strong) UILabel *countLabel; | |
| 25 | +@property (nonatomic, strong) UIView *textViewBackView; // 聊天输入框背景 | |
| 26 | +@property (nonatomic, strong) UITextField *textField; | |
| 27 | +@property (nonatomic, strong) UIButton *resignTextViewBtn; // 点击空白取消评论按钮 | |
| 28 | +@property (nonatomic, strong) UIButton *commentButton; | |
| 17 | 29 | |
| 18 | 30 | @end |
| 19 | 31 | |
| ... | ... | @@ -23,6 +35,9 @@ static NSString *titleCellId = @"titleCellId"; |
| 23 | 35 | { |
| 24 | 36 | self = [super initWithFrame:frame]; |
| 25 | 37 | if (self) { |
| 38 | + _commentArray = [[NSArray alloc] init]; | |
| 39 | + _cellHeightArrayM = [[NSMutableArray alloc] init]; | |
| 40 | + [self addNotification]; | |
| 26 | 41 | [self addSubview:self.tableview]; |
| 27 | 42 | } |
| 28 | 43 | return self; |
| ... | ... | @@ -33,29 +48,117 @@ static NSString *titleCellId = @"titleCellId"; |
| 33 | 48 | if (_model != model) { |
| 34 | 49 | _model = model; |
| 35 | 50 | } |
| 36 | - [self.tableview reloadData]; | |
| 51 | + if (model.desc) { | |
| 52 | + CGRect contentRect = [model.desc boundingRectWithSize:CGSizeMake(KScreenWidth-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil]; | |
| 53 | + _desHeight = contentRect.size.height; | |
| 54 | + } else { | |
| 55 | + _desHeight = 0; | |
| 56 | + } | |
| 57 | + [self getCommentListWithPid:@"123"]; | |
| 58 | + [self getCommentCountWithPid:@"123"]; | |
| 59 | +} | |
| 60 | + | |
| 61 | +#pragma mark - 获取评论列表 | |
| 62 | +- (void)getCommentListWithPid:(NSString *)pid { | |
| 63 | + | |
| 64 | + [[CNLiveCommentManager sharedCNLiveCommentManager] getCommentListWithProgramId:pid page:@"1" pageSize:@"10" success:^(CNLiveCommentListResult *result) { | |
| 65 | + | |
| 66 | + _commentArray = result.comments; | |
| 67 | + if (_commentArray && _commentArray.count > 0) { | |
| 68 | + for (CNLiveCommentDetailInfoResult *result in _commentArray) { | |
| 69 | + if (result.content) { | |
| 70 | + CGRect contentRect = [result.content boundingRectWithSize:CGSizeMake(KScreenWidth-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil]; | |
| 71 | + CGFloat contentHeight = contentRect.size.height; | |
| 72 | + [_cellHeightArrayM addObject:[NSString stringWithFormat:@"%f",contentHeight]]; | |
| 73 | + } else { | |
| 74 | + [_cellHeightArrayM addObject:@"0"]; | |
| 75 | + } | |
| 76 | + } | |
| 77 | + } | |
| 78 | + | |
| 79 | + [self.tableview reloadData]; | |
| 80 | + } error:^(NSString *error) { | |
| 81 | + NSLog(@"获取评论列表失败"); | |
| 82 | + }]; | |
| 83 | +} | |
| 84 | + | |
| 85 | +#pragma mark - 获取评论数 | |
| 86 | +- (void)getCommentCountWithPid:(NSString *)pid { | |
| 87 | + | |
| 88 | + [[CNLiveCommentManager sharedCNLiveCommentManager] getCommentCountWithProgramIds:@[pid] completion:^(NSString *errorCode, NSString *errorMsg, NSArray<CNLiveCommentCountResult *> *commentArray) { | |
| 89 | + | |
| 90 | + if ([errorCode isEqualToString:@"0"]) { | |
| 91 | + CNLiveCommentCountResult *result = [commentArray lastObject]; | |
| 92 | + self.countLabel.text = result.count; | |
| 93 | + } | |
| 94 | + }]; | |
| 37 | 95 | } |
| 38 | 96 | |
| 39 | 97 | #pragma mark - UITableViewDelegate !!!!!!!!!!!!!!!!!!!!! |
| 40 | 98 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { |
| 41 | - return SCREEN_WIDTH*9/16+40; | |
| 99 | + if (indexPath.section == 0) { | |
| 100 | + return _desHeight+70; | |
| 101 | + } else { | |
| 102 | + return [_cellHeightArrayM[indexPath.row] floatValue] + 60; | |
| 103 | + } | |
| 42 | 104 | } |
| 43 | 105 | |
| 44 | 106 | #pragma mark - UITableViewDataSource !!!!!!!!!!!!!!!!!!!!!!! |
| 107 | +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { | |
| 108 | + return 2; | |
| 109 | +} | |
| 110 | + | |
| 45 | 111 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
| 46 | 112 | |
| 47 | - return 2; | |
| 113 | + if (section == 0) { | |
| 114 | + return 1; | |
| 115 | + } else { | |
| 116 | + return _commentArray.count; | |
| 117 | + } | |
| 48 | 118 | } |
| 49 | 119 | |
| 50 | 120 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
| 51 | 121 | |
| 52 | - if (indexPath.row == 0) { | |
| 53 | - | |
| 122 | + if (indexPath.section == 0) { | |
| 123 | + LVCCommentTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:titleCellId forIndexPath:indexPath]; | |
| 124 | + cell.selectionStyle = UITableViewCellSelectionStyleNone; | |
| 125 | + cell.model = self.model; | |
| 126 | + return cell; | |
| 127 | + } else { | |
| 128 | + LVCCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:commentCellId forIndexPath:indexPath]; | |
| 129 | + cell.selectionStyle = UITableViewCellSelectionStyleNone; | |
| 130 | + cell.result = _commentArray[indexPath.row]; | |
| 131 | + return cell; | |
| 132 | + } | |
| 133 | +} | |
| 134 | + | |
| 135 | +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { | |
| 136 | + | |
| 137 | + if (section == 1) { | |
| 138 | + UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 90)]; | |
| 139 | + headerView.backgroundColor = [UIColor whiteColor]; | |
| 140 | + UILabel *commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 50, 40)]; | |
| 141 | + commentLabel.font = [UIFont systemFontOfSize:20]; | |
| 142 | + commentLabel.text = @"评论"; | |
| 143 | + [headerView addSubview:commentLabel]; | |
| 144 | + [headerView addSubview:self.countLabel]; | |
| 145 | + [headerView addSubview:self.commentButton]; | |
| 146 | + UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 89, KScreenWidth, 1)]; | |
| 147 | + line.backgroundColor = [UIColor lightGrayColor]; | |
| 148 | + [headerView addSubview:line]; | |
| 149 | + return headerView; | |
| 150 | + } else { | |
| 151 | + return nil; | |
| 54 | 152 | } |
| 153 | +} | |
| 154 | + | |
| 155 | +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { | |
| 55 | 156 | |
| 56 | - LVCCommentTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:titleCellId forIndexPath:indexPath]; | |
| 57 | - cell.model = self.model; | |
| 58 | - return cell; | |
| 157 | + if (section == 0) { | |
| 158 | + return 0; | |
| 159 | + } else { | |
| 160 | + return 90; | |
| 161 | + } | |
| 59 | 162 | } |
| 60 | 163 | |
| 61 | 164 | #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!! |
| ... | ... | @@ -67,10 +170,151 @@ static NSString *titleCellId = @"titleCellId"; |
| 67 | 170 | _tableview.dataSource = self; |
| 68 | 171 | _tableview.showsVerticalScrollIndicator = NO; |
| 69 | 172 | _tableview.showsHorizontalScrollIndicator = NO; |
| 70 | - _tableview.separatorStyle = UITableViewCellSeparatorStyleNone; | |
| 71 | 173 | [_tableview registerClass:[LVCCommentTitleCell class] forCellReuseIdentifier:titleCellId]; |
| 174 | + [_tableview registerClass:[LVCCommentCell class] forCellReuseIdentifier:commentCellId]; | |
| 72 | 175 | } |
| 73 | 176 | return _tableview; |
| 74 | 177 | } |
| 75 | 178 | |
| 179 | +- (UILabel *)countLabel { | |
| 180 | + if (!_countLabel) { | |
| 181 | + _countLabel = [[UILabel alloc] initWithFrame:CGRectMake(KScreenWidth-40, 0, 40, 40)]; | |
| 182 | + _countLabel.font = [UIFont systemFontOfSize:20]; | |
| 183 | + _countLabel.text = @"0"; | |
| 184 | + } | |
| 185 | + return _countLabel; | |
| 186 | +} | |
| 187 | + | |
| 188 | +- (UIView *)textViewBackView { | |
| 189 | + if (!_textViewBackView) { | |
| 190 | + _textViewBackView = [[UIView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, 40)]; | |
| 191 | + _textViewBackView.backgroundColor = [UIColor colorWithRed:(230.0/255.0) green:(230.0/255.0) blue:(230.0/255.0) alpha:1]; | |
| 192 | + [_textViewBackView addSubview:self.textField]; | |
| 193 | + } | |
| 194 | + return _textViewBackView; | |
| 195 | +} | |
| 196 | + | |
| 197 | +- (UITextField *)textField { | |
| 198 | + if (!_textField) { | |
| 199 | + _textField = [[UITextField alloc] initWithFrame:CGRectMake(5, 5, KScreenWidth - 10, 30)]; | |
| 200 | + _textField.backgroundColor = [UIColor lightGrayColor]; | |
| 201 | + _textField.returnKeyType = UIReturnKeySend; | |
| 202 | + _textField.font = [UIFont systemFontOfSize:14]; | |
| 203 | + _textField.delegate = self; | |
| 204 | + _textField.enablesReturnKeyAutomatically = YES; | |
| 205 | + } | |
| 206 | + return _textField; | |
| 207 | +} | |
| 208 | + | |
| 209 | +- (UIButton *)resignTextViewBtn { | |
| 210 | + if (!_resignTextViewBtn) { | |
| 211 | + _resignTextViewBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 212 | + [_resignTextViewBtn setFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; | |
| 213 | + [_resignTextViewBtn addTarget:self action:@selector(commentBackBtnAction:) forControlEvents:UIControlEventTouchUpInside]; | |
| 214 | + [_resignTextViewBtn addSubview:self.textViewBackView]; | |
| 215 | + } | |
| 216 | + return _resignTextViewBtn; | |
| 217 | +} | |
| 218 | + | |
| 219 | +- (UIButton *)commentButton { | |
| 220 | + if (!_commentButton) { | |
| 221 | + _commentButton = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 222 | + _commentButton.frame = CGRectMake(10, 40, KScreenWidth-20, 40); | |
| 223 | + _commentButton.backgroundColor = [UIColor colorWithRed:(230.0/255.0) green:(230.0/255.0) blue:(230.0/255.0) alpha:1]; | |
| 224 | + [_commentButton setTitleColor:[UIColor grayColorCNLive] forState:UIControlStateNormal]; | |
| 225 | + [_commentButton setTitle:@" 我来说两句....." forState:UIControlStateNormal]; | |
| 226 | + _commentButton.layer.cornerRadius = 15; | |
| 227 | + _commentButton.layer.masksToBounds = YES; | |
| 228 | + [_commentButton addTarget:self action:@selector(commentBtnAction:) forControlEvents:UIControlEventTouchUpInside]; | |
| 229 | + } | |
| 230 | + return _commentButton; | |
| 231 | +} | |
| 232 | + | |
| 233 | +#pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 234 | +- (void)addNotification { | |
| 235 | + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; | |
| 236 | + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; | |
| 237 | +} | |
| 238 | + | |
| 239 | +- (void)commentBtnAction:(UIButton *)button { | |
| 240 | + [self addSubview:self.resignTextViewBtn]; | |
| 241 | + [self.textField becomeFirstResponder]; | |
| 242 | +} | |
| 243 | + | |
| 244 | +- (void)commentBackBtnAction:(UIButton *)button { | |
| 245 | + [button removeFromSuperview]; | |
| 246 | +} | |
| 247 | + | |
| 248 | +#pragma mark - UITextFieldDelegate | |
| 249 | +- (BOOL)textFieldShouldReturn:(UITextField *)textField { | |
| 250 | + | |
| 251 | + [[CNLiveCommentManager sharedCNLiveCommentManager] commentOnProgramWithProgramId:@"123" sid:@"555" comment:textField.text completion:^(NSString *errorCode, NSString *errorMsg) { | |
| 252 | + | |
| 253 | + if ([errorCode isEqualToString:@"0"]) { | |
| 254 | + textField.text = @""; | |
| 255 | + [textField resignFirstResponder]; | |
| 256 | + [self getCommentListWithPid:@"123"]; | |
| 257 | + [self getCommentCountWithPid:@"123"]; | |
| 258 | + } | |
| 259 | + }]; | |
| 260 | + return YES; | |
| 261 | +} | |
| 262 | + | |
| 263 | +#pragma mark <KeyboardNotificationAction> | |
| 264 | +- (void)keyboardWillShow:(NSNotification *)notification { | |
| 265 | + | |
| 266 | + CGRect keyboardRect = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; | |
| 267 | + UIViewAnimationCurve curve = [[notification.userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue]; | |
| 268 | + double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; | |
| 269 | + | |
| 270 | + [UIView animateWithDuration:duration | |
| 271 | + delay:0.0f | |
| 272 | + options:[self animationOptionsForCurve:curve] | |
| 273 | + animations:^{ | |
| 274 | + | |
| 275 | + CGRect inputViewFrame = self.textViewBackView.frame; | |
| 276 | + if (keyboardRect.origin.y == KScreenHeight) { | |
| 277 | + self.textViewBackView.frame = CGRectMake(inputViewFrame.origin.x, | |
| 278 | + self.frame.size.height-(inputViewFrame.size.height), | |
| 279 | + inputViewFrame.size.width, | |
| 280 | + inputViewFrame.size.height); | |
| 281 | + } else { | |
| 282 | + | |
| 283 | + self.textViewBackView.frame = CGRectMake(inputViewFrame.origin.x, | |
| 284 | + self.frame.size.height-keyboardRect.size.height-_textViewBackView.frame.size.height, | |
| 285 | + inputViewFrame.size.width, | |
| 286 | + inputViewFrame.size.height); | |
| 287 | + | |
| 288 | + } | |
| 289 | + } | |
| 290 | + completion:^(BOOL finished) { | |
| 291 | + }]; | |
| 292 | +} | |
| 293 | + | |
| 294 | +- (void)keyboardWillHide:(NSNotification *)notification | |
| 295 | +{ | |
| 296 | + [self.textViewBackView setFrame:CGRectMake(0, KScreenHeight, KScreenWidth, self.textViewBackView.frame.size.height)]; | |
| 297 | + [self.resignTextViewBtn removeFromSuperview]; | |
| 298 | +} | |
| 299 | + | |
| 300 | +- (UIViewAnimationOptions)animationOptionsForCurve:(UIViewAnimationCurve)curve | |
| 301 | +{ | |
| 302 | + switch (curve) { | |
| 303 | + case UIViewAnimationCurveEaseInOut: | |
| 304 | + return UIViewAnimationOptionCurveEaseInOut; | |
| 305 | + break; | |
| 306 | + case UIViewAnimationCurveEaseIn: | |
| 307 | + return UIViewAnimationOptionCurveEaseIn; | |
| 308 | + break; | |
| 309 | + case UIViewAnimationCurveEaseOut: | |
| 310 | + return UIViewAnimationOptionCurveEaseOut; | |
| 311 | + break; | |
| 312 | + case UIViewAnimationCurveLinear: | |
| 313 | + return UIViewAnimationOptionCurveLinear; | |
| 314 | + break; | |
| 315 | + } | |
| 316 | + | |
| 317 | + return kNilOptions; | |
| 318 | +} | |
| 319 | + | |
| 76 | 320 | @end | ... | ... |
LiveVideoCloud/PrefixHeader.pch
LiveVideoCloud/animation.xcassets/videoSupport.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "filename" : "videoSupport.png", | |
| 6 | + "scale" : "1x" | |
| 7 | + }, | |
| 8 | + { | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "idiom" : "universal", | |
| 14 | + "scale" : "3x" | |
| 15 | + } | |
| 16 | + ], | |
| 17 | + "info" : { | |
| 18 | + "version" : 1, | |
| 19 | + "author" : "xcode" | |
| 20 | + } | |
| 21 | +} | |
| 0 | 22 | \ No newline at end of file | ... | ... |
LiveVideoCloud/animation.xcassets/videoSupport.imageset/videoSupport.png
0 → 100644
1.94 KB
LiveVideoCloud/animation.xcassets/videoSupportNormal.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "filename" : "videoSupportNormal.png", | |
| 6 | + "scale" : "1x" | |
| 7 | + }, | |
| 8 | + { | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "idiom" : "universal", | |
| 14 | + "scale" : "3x" | |
| 15 | + } | |
| 16 | + ], | |
| 17 | + "info" : { | |
| 18 | + "version" : 1, | |
| 19 | + "author" : "xcode" | |
| 20 | + } | |
| 21 | +} | |
| 0 | 22 | \ No newline at end of file | ... | ... |
LiveVideoCloud/animation.xcassets/videoSupportNormal.imageset/videoSupportNormal.png
0 → 100644
2.01 KB