// // AnswerContentAskCell.m // ThePaperBase // // Created by zhousan on 15/11/19. // Copyright © 2015年 scar1900. All rights reserved. // #import "AnswerContentAskCell.h" #import "commentTableController.h" #import "askTableController.h" @implementation AnswerContentAskCell - (void)subLayoutSubViews { __weak typeof(self) weakSelf = self; [self.backView makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self); make.bottom.equalTo(self); make.left.equalTo(self).offset(10); make.right.equalTo(self).offset(-10); }]; [self.menuButton makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(weakSelf.aswerContentLabel); }]; [self.expandBtn makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.backView.left); make.right.equalTo(weakSelf.backView.right); make.top.equalTo(weakSelf.aswerContentLabel.bottom); make.height.mas_equalTo(25); }]; } - (void)menuTap:(UIButton*)btn { [self becomeFirstResponder]; UIMenuItem *commentBack = [[UIMenuItem alloc] initWithTitle:@"回复"action:@selector(commentBack:)]; UIMenuItem *copy = [[UIMenuItem alloc] initWithTitle:@"复制"action:@selector(copyText:)]; UIMenuItem *praise = [[UIMenuItem alloc] initWithTitle:@"点赞"action:@selector(praise:)]; UIMenuItem *delete = [[UIMenuItem alloc] initWithTitle:@"删除"action:@selector(deleteComment:)]; UIMenuItem *share = [[UIMenuItem alloc] initWithTitle:@"分享" action:@selector(shareTo:)]; UIMenuController *menu = [UIMenuController sharedMenuController]; if (menu.menuVisible) { [menu setMenuVisible:NO animated:YES]; return; } NSDictionary *userInfo = self.commentBO.userInfo; userBO *user = setJsonDicToDataModel(userInfo, [userBO class]); if ([TPUserDefault instance].userBO && [user.userId longLongValue] == [[TPUserDefault instance].userBO.userId longLongValue]) { [menu setMenuItems:[NSArray arrayWithObjects:delete,commentBack, copy,share, praise, nil]]; }else { [menu setMenuItems:[NSArray arrayWithObjects:commentBack, copy,share, praise, nil]]; } [menu setTargetRect:self.aswerContentLabel.frame inView:self]; [menu setMenuVisible:YES animated:YES]; } - (void)deleteComment:(id)sender { UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"是否确认删除此发言?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"删除",nil]; [alert show]; } - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { [super canPerformAction:action withSender:sender]; if ( action == @selector(commentBack:) || action == @selector(copyText:) || action == @selector(praise:) || action == @selector(deleteComment:)|| action == @selector(shareTo:)) { return YES; } else { return NO; } } - (void)commentBack:(id)sender { if ([self.delegate respondsToSelector:@selector(gotoCommentWith:)]) { [self.delegate gotoCommentWith:self.commentBO]; }; } -(void)shareTo:(id)sender { if ([self.delegate respondsToSelector:@selector(gotoShare:index:)]) { [self.delegate gotoShare:self.commentBO index:self.indexPath]; } } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex != 0) { [MobClick event:@"57"]; NSDictionary *dic = @{@"commentIds":self.commentBO.commentId,@"commentType":@"1"}; __weak typeof(self) Self = self; [Remote doJsonActionWithBlock:2001 requestUrl:removeCommentmspURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) { if (success) { [MobClick event:@"27"]; [Self.delegate deleteCommentSuccess]; ShowMessage(@"删除成功",YES); }else { ShowMessage(@"删除失败", NO); } }]; } } - (void)reLayoutSubViews { [super reLayoutSubViews]; } @end