// // topicContentTableController.m // ThePaperHD // // Created by scar1900 on 15/5/10. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "topicContentTableController.h" #import "tableScaleHeaderView.h" #import "UIScrollView+PullScale.h" #import "topicDescCell.h" #import "topicAskCell.h" #import "topicAnswerCell.h" #import "relateNewsCell.h" #import "relateTopicCell.h" #import "topicNoDataCell.h" #import "topicContentController.h" #import "hotAskListController.h" #import "hotAskListHomeController.h" #import "otherPersonHomepageController.h" #import "loginPopUpController.h" #define tableWidht 1230/2 #define kPullHeight 920/2 @protocol creatQaListHeaderDelegate - (void)clickToSortQaList:(NSString*)indexStr; @end @interface relateHeaderView : UITableViewHeaderFooterView { CGFloat padding; } @property(nonatomic, strong)UIView *colorView; @property(nonatomic, strong)UILabel *titleLable; @end @implementation relateHeaderView - (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithReuseIdentifier:reuseIdentifier]; if (self) { self.contentView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; [self.contentView addSubview:self.colorView]; [self.contentView addSubview:self.titleLable]; } return self; } - (UIView*)colorView { if (!_colorView) { _colorView = [[UIView alloc]initWithFrame:CGRectZero]; _colorView.backgroundColor = [UIColor colorWithHexString:BLUECOLOR]; } return _colorView; } - (UILabel*)titleLable { if (!_titleLable) { _titleLable = [[UILabel alloc]initWithFrame:CGRectZero]; _titleLable.font = appFont(19, NO); _titleLable.textColor = [UIColor colorWithHexString:TextBlack]; _titleLable.textAlignment = NSTextAlignmentLeft; _titleLable.backgroundColor = [UIColor clearColor]; } return _titleLable; } - (void)layoutSubviews { [super layoutSubviews]; padding = CGRectGetWidth(self.contentView.bounds)/2-1230/4; self.colorView.frame = CGRectMake(padding, CGRectGetHeight(self.contentView.bounds)-20, 5, 20); self.titleLable.frame = CGRectMake(CGRectGetMaxX(self.colorView.frame)+8, CGRectGetMinY(self.colorView.frame), 500, 20); } @end static NSString *qaNumCellId = @"topicQaNum cell"; @interface creatQaListHeaderView : UITableViewHeaderFooterView { CGFloat padding; } @property(nonatomic, strong)UIButton *firstBtn; @property(nonatomic, strong)UIButton *secondBtn; @property(nonatomic, assign)BOOL isCreat; @property(nonatomic, assign)NSInteger sortIndex; // 0待回复,热门 1 已回复,最新 @property(nonatomic, weak)id delegate; @end @implementation creatQaListHeaderView @synthesize delegate,isCreat = _isCreat; @synthesize sortIndex = _sortIndex; - (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithReuseIdentifier:reuseIdentifier]; if (self) { self.contentView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; [self.contentView addSubview:self.firstBtn]; [self.contentView addSubview:self.secondBtn]; } return self; } - (void)setSortIndex:(NSInteger)index { _sortIndex = index; if (index == 0) { self.firstBtn.selected = YES; self.secondBtn.selected = NO; }else { self.firstBtn.selected = NO; self.secondBtn.selected = YES; } } - (void)setIsCreat:(BOOL)creat { _isCreat = creat; [self setBtn:self.firstBtn]; [self setBtn:self.secondBtn]; } - (UIButton *)firstBtn { if (!_firstBtn) { _firstBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _firstBtn.tag = 1001; [_firstBtn addTarget:self action:@selector(clickFirstBtn:) forControlEvents:UIControlEventTouchUpInside]; } return _firstBtn; } - (UIButton*)secondBtn { if (!_secondBtn) { _secondBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _secondBtn.tag = 1002; [_secondBtn addTarget:self action:@selector(clickSectionBtn:) forControlEvents:UIControlEventTouchUpInside]; } return _secondBtn; } - (void)setBtn:(UIButton*)btn { [btn setBackgroundImage:imageWithUIColor([UIColor colorWithHexString:@"0xedf7fc"]) forState:UIControlStateNormal]; [btn setBackgroundImage:imageWithUIColor([UIColor colorWithHexString:BLUECOLOR]) forState:UIControlStateSelected]; [btn setBackgroundImage:imageWithUIColor([UIColor colorWithHexString:LIGHTGRAY]) forState:UIControlStateHighlighted]; btn.titleLabel.font = appFont(15, NO); [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected]; [btn setTitleColor:[UIColor colorWithHexString:LINECOLOR] forState:UIControlStateNormal]; if (self.isCreat) {//待回复,回复 if (btn.tag ==1001) { [btn setImage:Image(@"topic/waiteAnswer_s.png") forState:UIControlStateSelected]; [btn setImage:Image(@"topic/waiteAnswer.png") forState:UIControlStateNormal]; [btn setTitle:@"待回复" forState:UIControlStateNormal]; [btn setTitleEdgeInsets:UIEdgeInsetsMake(0, 40, 0, 25)]; }else{ [btn setImage:Image(@"topic/haveAnswer_s.png") forState:UIControlStateSelected]; [btn setImage:Image(@"topic/haveAnswer.png") forState:UIControlStateNormal]; [btn setTitle:@"已回复" forState:UIControlStateNormal]; [btn setTitleEdgeInsets:UIEdgeInsetsMake(0, 40, 0, 25)]; } }else{//热门,时间 if (btn.tag ==1001) { [btn setImage:Image(@"topic/hot_s.png") forState:UIControlStateSelected]; [btn setImage:Image(@"topic/hot.png") forState:UIControlStateNormal]; [btn setTitle:@"热门" forState:UIControlStateNormal]; [btn setTitleEdgeInsets:UIEdgeInsetsMake(0, 40, 0, 25)]; }else{ [btn setImage:Image(@"topic/almost.png") forState:UIControlStateNormal]; [btn setImage:Image(@"topic/almost_s.png") forState:UIControlStateSelected]; [btn setTitle:@"最新" forState:UIControlStateNormal]; [btn setTitleEdgeInsets:UIEdgeInsetsMake(0, 40, 0, 25)]; } } } - (void)clickFirstBtn:(UIButton*)btn { if ([self.delegate respondsToSelector:@selector(clickToSortQaList:)]) { [self.delegate clickToSortQaList:@"0"]; } if (btn.selected) { return; } btn.selected = !btn.selected; self.secondBtn.selected = !btn.selected; } - (void)clickSectionBtn:(UIButton*)btn { if ([self.delegate respondsToSelector:@selector(clickToSortQaList:)]) { [self.delegate clickToSortQaList:@"1"]; } if (btn.selected) { return; } btn.selected = !btn.selected; self.firstBtn.selected = !btn.selected; } - (void)layoutSubviews { [super layoutSubviews]; padding = CGRectGetWidth(self.contentView.bounds)/2-1230/4; self.firstBtn.frame = CGRectMake(padding, 20, tableWidht/2, 40); self.secondBtn.frame = CGRectMake(CGRectGetMaxX(self.firstBtn.frame), 20, tableWidht/2, 40); } @end @interface topicContentTableController () { NSMutableArray *heightList; NSInteger sectionNum; NSString *replyedNum; NSString *replayNum; NSString *waitReplyNum; CGFloat padding; BOOL isDescExpand; NSString *sortIndex; NSInteger qaSecion; NSIndexPath *lastIndexPath; CGFloat topContentHeight; } //@property(nonatomic, strong)UIImageView *backView; @property(nonatomic, strong)UILabel *contentLabel; @property(nonatomic, strong)UILabel *categoryLabel; @property(nonatomic, strong)UILabel *publishTimeLabel; @property(nonatomic, strong)UIImageView *categoryImg; @property(nonatomic, strong)UIButton *attentionBtn; @property(nonatomic, strong)NSMutableArray *dataList; @property(nonatomic, strong)NSMutableArray *qaList; @property(nonatomic, strong)NSMutableArray *relateContList; @property(nonatomic, strong)NSMutableArray *relateTopicList; @property(nonatomic, strong)hotAskListHomeController *hotAskVC; @property(nonatomic, strong)NSMutableArray *textColorArray; @end @implementation topicContentTableController @synthesize topicInfo = _topicInfo; @synthesize topicPageVO = _topicPageVO; @synthesize isCreat; @synthesize dataList = _dataList; @synthesize qaList; @synthesize relateContList,relateTopicList; @synthesize textColorArray; static NSString *creatQaListHeaderIdentifer = @"creatQaListHeader"; static NSString *relateHeaderIdentifer = @"replateHeader"; @synthesize currentIndex; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. sortIndex = @"0"; lastIndexPath = nil; isDescExpand = NO; [self configCanRefresh:NO canLoad:YES]; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; [self.tableView registerClass:[creatQaListHeaderView class] forHeaderFooterViewReuseIdentifier:creatQaListHeaderIdentifer]; [self.tableView registerClass:[relateHeaderView class] forHeaderFooterViewReuseIdentifier:relateHeaderIdentifer]; [self.tableView addPullScaleFuncInVC:self imageUrl:self.topicInfo.pic originalHeight:kPullHeight hasNavBar:NO]; [self.tableView setHeaderViewInsets:UIEdgeInsetsMake(-kPullHeight, 0, 0, 0)]; [self addSubViewInTableheader]; } - (void)addSubViewInTableheader { // [self.tableView.imageV addSubview:self.backView]; [self.tableView.imageV addSubview:self.contentLabel]; [self.tableView.imageV addSubview:self.categoryImg]; [self.tableView.imageV addSubview:self.categoryLabel]; // [self.categoryLabel addSubview:self.categoryImg]; [self.tableView.imageV addSubview:self.publishTimeLabel]; [self.tableView.imageV addSubview:self.statusLabel]; [self.tableView.imageV addSubview:self.attentionBtn]; } - (void)setTopicInfo:(TopicInfoBO *)topicData { _topicInfo = topicData; self.tableView.imageV.imageUrl = self.topicInfo.pic; self.contentLabel.text = self.topicInfo.title; self.categoryLabel.text = self.topicInfo.categoryName; self.publishTimeLabel.text = self.topicInfo.publishTime; NSString *statusStr = @""; if ([self.topicInfo.status intValue] == 0) { statusStr = @"待审核"; }else if ([self.topicInfo.status intValue] == 1) { if([self.topicInfo.replyedNum integerValue] <=0){//【需求】话题:增加提问征集中的状态(bug:4323) statusStr = @"提问征集中"; }else{ statusStr = @"进行中..."; } }else if ([self.topicInfo.status intValue] == 2) { statusStr = @"审核不通过"; }else if ([self.topicInfo.status intValue] == 3) { statusStr = @"已关闭提问"; } self.statusLabel.text = statusStr; if ([self.topicInfo.isAttented integerValue] ==1) { self.attentionBtn.selected = YES; [self.attentionBtn setTitle:@"已关注" forState:UIControlStateSelected]; }else{ self.attentionBtn.selected = NO; [self.attentionBtn setTitle:@"关注" forState:UIControlStateNormal]; } [self viewWillLayoutSubviews]; } - (void)setTopicPageVO:(topicInfoPageVO *)data { _topicPageVO = data; self.topicInfo = setJsonDicToDataModel(data.topicInfo, [TopicInfoBO class]); self.topicInfo.desc = data.topicInfo[@"description"]; NSString *newNums = data.topicInfo[@"newNums"]; if (newNums) { self.topicInfo.unNums = newNums; } [self setDataSource]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; __weak typeof(self) Self = self; if (self.hotAskVC && self.hotAskVC.isNeedHold) { [self presentController:self.hotAskVC animated:YES presentSize:hotAskListPopUpSize completion:^{ } dismiss:^{ if (!Self.hotAskVC.isNeedHold) { Self.hotAskVC = nil; } }]; } } -(void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; topContentHeight = heightForString(self.contentLabel.text, self.contentLabel.font,CGRectGetWidth(self.tableView.imageV.bounds)-60 , self.contentLabel.lineBreakMode); padding = CGRectGetWidth(self.view.bounds)/2-1230/4; [self.tableView resetPullScaleFrame:CGRectMake(padding, -920/2, tableWidht, 920/2)]; self.contentLabel.frame = CGRectMake(30, CGRectGetHeight(self.tableView.imageV.bounds)-topContentHeight-60, CGRectGetWidth(self.tableView.imageV.bounds)-60, topContentHeight+5); // self.categoryLabel.frame = CGRectMake(CGRectGetMaxX(self.tableView.imageV.bounds)/2-86/2, // CGRectGetHeight(self.tableView.imageV.bounds)/2-35/2, // 86, // 35); self.categoryLabel.frame = CGRectMake(CGRectGetMaxX(self.tableView.imageV.bounds)/2-86/2, CGRectGetMinY(self.contentLabel.frame)-70, 86, 35);//话题详情页,图片中的话题类型显示位置需要和标题行数对应,而不是固定(BUG:4507) self.categoryImg.frame = self.categoryLabel.frame; self.publishTimeLabel.frame = CGRectMake(45/2, CGRectGetHeight(self.tableView.imageV.bounds)-33, 150, 13); self.statusLabel.frame = CGRectMake(0, CGRectGetMinY(self.publishTimeLabel.frame), CGRectGetWidth(self.tableView.imageV.bounds), 13); self.attentionBtn.frame = CGRectMake(CGRectGetMaxX(self.tableView.imageV.bounds)-95, CGRectGetHeight(self.tableView.imageV.bounds)-54, 75, 37); [self.tableView reloadData]; } - (UILabel*)contentLabel { if (!_contentLabel) { _contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, CGRectGetHeight(self.tableView.imageV.bounds)-topContentHeight-60, CGRectGetWidth(self.tableView.imageV.bounds)-60, topContentHeight)]; _contentLabel.textColor = [UIColor whiteColor]; _contentLabel.font = appFont(30, NO); _contentLabel.textAlignment = NSTextAlignmentLeft; _contentLabel.backgroundColor = [UIColor clearColor]; _contentLabel.lineBreakMode = NSLineBreakByWordWrapping; _contentLabel.numberOfLines = 0; if (isIOS8) { _contentLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleTopMargin;//【需求】话题卡片视觉调整(BUG:4341) }else{ _contentLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight;//【需求】话题卡片视觉调整(BUG:4341) } } return _contentLabel; } - (UILabel*)categoryLabel { if (!_categoryLabel) { _categoryLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _categoryLabel.textColor = [UIColor whiteColor]; _categoryLabel.font = appFont(14, NO); _categoryLabel.textAlignment = NSTextAlignmentCenter; _categoryLabel.backgroundColor = [UIColor clearColor]; _categoryLabel.autoresizingMask = AutoresizingAuto; _categoryLabel.layer.borderColor = [UIColor whiteColor].CGColor; _categoryLabel.layer.borderWidth = 1; } return _categoryLabel; } -(UIImageView *)categoryImg{ if (!_categoryImg) { _categoryImg = [[UIImageView alloc]initWithFrame:CGRectZero]; _categoryImg.image = Image(@"topic/topicListTop.png"); _categoryImg.autoresizingMask = AutoresizingAuto; } return _categoryImg; } - (UILabel*)publishTimeLabel { if (!_publishTimeLabel) { _publishTimeLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _publishTimeLabel.textColor = [UIColor whiteColor]; _publishTimeLabel.font = appFont(11, NO); _publishTimeLabel.textAlignment = NSTextAlignmentLeft; _publishTimeLabel.backgroundColor = [UIColor clearColor]; _publishTimeLabel.autoresizingMask = AutoresizingAuto; } return _publishTimeLabel; } - (UILabel*)statusLabel { if (!_statusLabel) { _statusLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _statusLabel.textColor = [UIColor whiteColor]; _statusLabel.font = appFont(11, NO); _statusLabel.textAlignment = NSTextAlignmentCenter; _statusLabel.backgroundColor = [UIColor clearColor]; _statusLabel.autoresizingMask = AutoresizingAuto; } return _statusLabel; } -(UIButton *)attentionBtn{ if (!_attentionBtn) { _attentionBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _attentionBtn.frame = CGRectMake(CGRectGetMaxX(self.tableView.imageV.bounds)-95, CGRectGetHeight(self.tableView.imageV.bounds)-54, 75, 37); _attentionBtn.layer.cornerRadius = 2; _attentionBtn.layer.borderColor = [UIColor whiteColor].CGColor; _attentionBtn.layer.borderWidth = 1; [_attentionBtn setTitle:@"关注" forState:UIControlStateNormal]; [_attentionBtn setTitle:@"已关注" forState:UIControlStateSelected]; [_attentionBtn addTarget:self action:@selector(attentionEvent:) forControlEvents:UIControlEventTouchUpInside]; _attentionBtn.titleLabel.font = appFont(19, NO); _attentionBtn.autoresizingMask = AutoresizingAuto; } return _attentionBtn; } -(void) attentionEvent:(UIButton*)btn{ if (![TPUserDefault instance].userBO) { loginPopUpController *loginVC = loginPopUpController.new; __weak typeof(self) Self = self; [self presentController:loginVC animated:YES presentSize:loginPopUpSize completion:^{ } dismiss:^{ [Self attention:btn]; }]; }else { [self attention:btn]; } } - (void)attention:(UIButton*)btn { btn.selected = !btn.selected; NSDictionary *dic = @{@"ot":@"1",@"commentId":self.topicInfo.topicId}; if (btn.selected) { // if ([TPUserDefault instance].userBO) { [Remote doJsonActionWithBlock:1 requestUrl:addAttentionURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) { if (success) { [MobClick event:@"34"]; ShowMessage(@"关注成功", YES); btn.selected = YES; TopicInfoBO* topicData = self.topicInfo; topicData.isAttented = @"1"; [MobClick event:@"39"]; }else { ShowTextMessage(message); btn.selected = NO; } }]; // }else { // __weak typeof(self) Self = self; // [self pushToLoginVC:^{ // [Self dismissPushController]; // // if (![TPUserDefault instance].userBO) { // return; // } // [Remote doJsonActionWithBlock:1 requestUrl:addAttentionURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) { // if (success) { // ShowMessage(@"关注成功", YES); // btn.selected = isToFocus; // commentObjectVO* commentData = Self.hotAskVC.qaDataSource[0]; // commentData.isAttented = @"1"; // }else { // ShowTextMessage(message); // } // }]; // }]; // } }else { __weak typeof(self) Self = self; [Remote doJsonActionWithBlock:1 requestUrl:cancelAttentionURL parameter:dic withWaitCursor:YES completion:^(BOOL success, NSString *message, id responseData) { if (success) { ShowMessage(@"取消关注", YES); btn.selected = NO; TopicInfoBO* topicData = Self.topicInfo; topicData.isAttented = @"0"; }else { ShowTextMessage(message); btn.selected = YES; } }]; } } #pragma mark - dataSource - (void)setDataSource { if (isCreat) { [self remoteAskForMyQaList:sortIndex]; }else { if (self.currentIndex) { sortIndex = self.currentIndex; }else { sortIndex = @"0"; } [self remmoteAskForOtherQaList:sortIndex]; } } - (void)isCreatDataSource:(NSString*)status { self.dataList = [NSMutableArray array]; heightList = [NSMutableArray array]; sectionNum = 0; NSMutableArray *tempDataList = [NSMutableArray array]; NSString *topicDesc = self.topicInfo.desc; [tempDataList addObject:topicDesc]; sectionNum = sectionNum + 1; CGFloat descHeight = heightForString(topicDesc, appFont(14, NO), tableWidht, NSLineBreakByWordWrapping)+15; if (descHeight > 83) { if (!isDescExpand) { descHeight = 83 + 13 + 30; }else { descHeight = descHeight + 13 + 30; } }else { descHeight = descHeight + 13 + 15; } [heightList addObject:[NSString stringWithFormat:@"%f",descHeight]]; NSMutableArray *tempQaList = [NSMutableArray array]; NSMutableArray *tempHeightList = [NSMutableArray array]; // textColorArray = [NSMutableArray arrayWithObjects:waitReplyNum,replayNum,nil]; NSString *strString = [NSString stringWithFormat:@"待回复提问%@个,已回复提问%@个",waitReplyNum,replyedNum]; [tempQaList addObject:strString]; [tempHeightList addObject:@"30"]; [self.qaList enumerateObjectsUsingBlock:^(commentObjectVO* obj, NSUInteger idx, BOOL *stop) { if ([status intValue] == 0) { [tempQaList addObject:obj]; CGFloat askHeight = 114/2; CGFloat askContentHeight = returnTextHeightWithRTLabel(obj.content, tableWidht, appFont(interactionFontSize, NO), 10); askHeight = askHeight + askContentHeight + 20; [tempHeightList addObject:[NSString stringWithFormat:@"%f",askHeight]]; }else { [tempQaList addObject:obj]; CGFloat askHeight = 114/2; CGFloat askContentHeight = returnTextHeightWithRTLabel(obj.content, tableWidht, appFont(interactionFontSize, NO), 10); askHeight = askHeight + askContentHeight + 20; [tempHeightList addObject:[NSString stringWithFormat:@"%f",askHeight]]; NSArray *answerList = obj.answerList; [answerList enumerateObjectsUsingBlock:^(id dic, NSUInteger index, BOOL *stop1) { commentObjectVO *answerBO = setJsonDicToDataModel(dic, [commentObjectVO class]); [tempQaList addObject:answerBO]; // CGFloat askHeight = 114/2; // CGFloat askContentHeight = returnTextHeightWithRTLabel(answerBO.content, tableWidht, appFont(interactionFontSize, NO), 10); // 修正1.6.8的RTLable相关Crash(bug:5925) CGFloat answerHeight = 114/2; CGFloat answerContentHeight = heightForAttributeStringWithLabel(getLineSpaceAttributedString(answerBO.content, 10, appFont(interactionFontSize, NO)), tableWidht, appFont(interactionFontSize, NO)); answerHeight = answerHeight + answerContentHeight + 20; [tempHeightList addObject:[NSString stringWithFormat:@"%f",answerHeight]]; }]; } }]; [tempDataList addObject:tempQaList]; [heightList addObject:tempHeightList]; sectionNum = sectionNum + 1; self.dataList = tempDataList; } - (void)otherDataSource:(NSString*)status nextUrl:(NSString*)url{ self.dataList = [NSMutableArray array]; heightList = [NSMutableArray array]; self.relateContList = [NSMutableArray array]; self.relateTopicList = [NSMutableArray array]; sectionNum = 0; NSMutableArray *tempDataList = [NSMutableArray array]; NSArray *reContentsList = self.topicPageVO.relateConts; [reContentsList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { listContObjectVO *listBO = setJsonDicToDataModel(obj, [listContObjectVO class]); [self.relateContList addObject:listBO]; }]; NSArray *reTopicList = self.topicPageVO.relateTopics; [reTopicList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { TopicInfoBO *topic = setJsonDicToDataModel(obj, [TopicInfoBO class]); [self.relateTopicList addObject:topic]; }]; NSString *topicDesc = self.topicInfo.desc; [tempDataList addObject:topicDesc]; sectionNum = sectionNum + 1; CGFloat descHeight = heightForString(topicDesc, appFont(14, NO), tableWidht, NSLineBreakByWordWrapping)+15; if (descHeight > 83) { if (!isDescExpand) { descHeight = 83 + 13 + 30; }else { descHeight = descHeight + 13 + 30; } }else { descHeight = descHeight + 13 + 15; } [heightList addObject:[NSString stringWithFormat:@"%f",descHeight]]; if (self.relateContList.count > 0) { //相关新闻 sectionNum = sectionNum + 1; NSMutableArray *array = [NSMutableArray array]; NSMutableArray *tempHeightList = [NSMutableArray array]; [self.relateContList enumerateObjectsUsingBlock:^(listContObjectVO* obj, NSUInteger idx, BOOL *stop) { [array addObject:obj]; CGFloat listContHeight = heightForString(obj.name, appFont(18, NO), tableWidht, NSLineBreakByWordWrapping); listContHeight = listContHeight + 15 + 40; [tempHeightList addObject:[NSString stringWithFormat:@"%f",listContHeight]]; }]; [tempDataList addObject:array]; [heightList addObject:tempHeightList]; } NSMutableArray *tempQaList = [NSMutableArray array]; NSMutableArray *tempHeightList = [NSMutableArray array]; if (self.qaList.count > 0) { NSString *strString = [NSString stringWithFormat:@"共%d个提问,%@个回复",[self.topicInfo.waitReplyNum intValue] + [self.topicInfo.replyedNum intValue],replayNum]; [tempQaList addObject:strString]; [tempHeightList addObject:@"30"]; }else { NSString *strString = @""; if ([self.topicInfo.waitReplyNum integerValue] <=0) { strString = @"题主尚未开始回答"; }else{ strString = [NSString stringWithFormat:@"共有%d个提问,题主尚未开始回答",[self.topicInfo.waitReplyNum intValue] + [self.topicInfo.replyedNum intValue]]; } // NSString *strString = @"题主尚未开始回答"; [tempQaList addObject:strString]; [tempHeightList addObject:@"30"]; } [self.qaList enumerateObjectsUsingBlock:^(commentObjectVO* obj, NSUInteger idx, BOOL *stop) { [tempQaList addObject:obj]; CGFloat askHeight = 114/2; CGFloat askContentHeight = returnTextHeightWithRTLabel(obj.content, tableWidht, appFont(interactionFontSize, NO), 10); askHeight = askHeight + askContentHeight + 20; [tempHeightList addObject:[NSString stringWithFormat:@"%f",askHeight]]; NSArray *answerList = obj.answerList; [answerList enumerateObjectsUsingBlock:^(id dic, NSUInteger index, BOOL *stop1) { commentObjectVO *answerBO = setJsonDicToDataModel(dic, [commentObjectVO class]); [tempQaList addObject:answerBO]; // 修正1.6.8的RTLable相关Crash(bug:5925) CGFloat answerHeight = 114/2; CGFloat answerContentHeight = heightForAttributeStringWithLabel(getLineSpaceAttributedString(answerBO.content, 10, appFont(interactionFontSize, NO)), tableWidht, appFont(interactionFontSize, NO)); answerHeight = answerHeight + answerContentHeight + 20; [tempHeightList addObject:[NSString stringWithFormat:@"%f",answerHeight]]; // CGFloat askHeight = 114/2; // CGFloat askContentHeight = returnTextHeightWithRTLabel(answerBO.content, tableWidht, appFont(interactionFontSize, NO), 10); // askHeight = askHeight + askContentHeight + 20; // [tempHeightList addObject:[NSString stringWithFormat:@"%f",askHeight]]; }]; }]; sectionNum = sectionNum + 1; [tempDataList addObject:tempQaList]; [heightList addObject:tempHeightList]; if(self.qaList.count ==0){//【需求】话题:用户页面,总提问数和回复数的显示(bug:4312) [heightList addObject:@"400"]; [tempDataList addObject:@"noData"]; self.tableView.tableFooterView = nil; sectionNum = sectionNum + 1; } if (isBlankString(url)) { if (self.relateTopicList.count > 0) { //相关话题 sectionNum = sectionNum + 1; NSMutableArray *array = [NSMutableArray array]; NSMutableArray *tempHeightList = [NSMutableArray array]; [self.relateTopicList enumerateObjectsUsingBlock:^(TopicInfoBO* obj, NSUInteger idx, BOOL *stop) { [array addObject:obj]; CGFloat listContHeight = heightForString(obj.title, appFont(18, NO), tableWidht, NSLineBreakByWordWrapping); listContHeight = listContHeight + 50 + 15; [tempHeightList addObject:[NSString stringWithFormat:@"%f",listContHeight]]; }]; [tempDataList addObject:array]; [heightList addObject:tempHeightList]; } } self.dataList = tempDataList; } - (void)setDataList:(NSMutableArray *)list { _dataList = list; if (!list || list.count == 0) { return; } } - (void)remoteAskForMyQaList:(NSString*)status{ [self startHud]; NSDictionary *dic = @{@"status":status,@"topicId":self.topicInfo.topicId}; [Remote doJsonAction:0 requestUrl:myTopicQaListURL parameter:dic delegate:self]; } - (void)remmoteAskForOtherQaList:(NSString*)status { [self startHud]; if ([status intValue] == 0) { status = @"1"; }else status = @"0"; NSDictionary *dic = @{@"sort":status,@"topicId":self.topicInfo.topicId}; [Remote doJsonAction:1 requestUrl:topicQaListURL parameter:dic delegate:self]; } #pragma mark - remote delegate -(void)topicToOther:(commentObjectVO *)comment{ otherPersonHomepageController *otherVC = [otherPersonHomepageController new]; otherVC.commentBo = comment; [self.navigationController pushViewController:otherVC animated:YES]; } - (void)startWaitCursor:(int)actionTag { } - (void)stopWaitCursor:(int)actionTag { } - (void)startHud { if (!self.hud) { self.hud = [MBProgressHUD showHUDAddedTo:KEY_WINDOW animated:YES]; self.hud.mode = MBProgressHUDModeIndeterminate; self.hud.userInteractionEnabled = YES; self.hud.dimBackground = NO; UIColor *hudColor = [UIColor colorWithRed:76.5f/255.f green:76.5f/255.f blue:76.5f/255.f alpha:0.9f]; self.hud.color = hudColor; self.hud.cornerRadius = 4; self.hud.removeFromSuperViewOnHide = YES; } } - (void)stopHud { if (self.hud) { [self.hud hide:YES]; self.hud = nil; } } - (void)remoteResponsSuccess:(int)actionTag withResponsData:(id)responsData { if (actionTag == 0) { BOOL isFirst = NO; if (!self.dataList && self.dataList.count == 0) { isFirst = YES; } replyedNum = responsData[@"replyedNum"]; waitReplyNum = responsData[@"waitReplyNum"]; self.qaList = [NSMutableArray array]; NSArray *temp = responsData[@"qaList"]; [temp enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { commentObjectVO *comment = setJsonDicToDataModel(obj, [commentObjectVO class]); [self.qaList addObject:comment]; }]; [self isCreatDataSource:sortIndex]; [self loadSuccess]; NSString *url = responsData[@"nextUrl"]; self.nextUrl = url; if (isFirst) { [self.tableView reloadData]; }else { [self.tableView reloadData]; CGRect rect = [self.tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:qaSecion]]; CGFloat height = [heightList[0] floatValue]; rect.origin.y = rect.origin.y + kPullHeight -height+64; [self.tableView scrollRectToVisible:rect animated:YES]; } [self stopHud]; }else if (actionTag == 1) { BOOL isFirst = NO; if (!self.dataList && self.dataList.count == 0) { isFirst = YES; } replayNum = responsData[@"recordTotal"]; self.qaList = [NSMutableArray array]; NSArray *temp = responsData[@"qaList"]; [temp enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { commentObjectVO *comment = setJsonDicToDataModel(obj, [commentObjectVO class]); [self.qaList addObject:comment]; }]; [self loadSuccess]; NSString *url = responsData[@"nextUrl"]; self.nextUrl = url; [self otherDataSource:sortIndex nextUrl:url]; if (isFirst) { [self.tableView reloadData]; }else { [self.tableView reloadData]; CGRect rect = [self.tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:qaSecion]]; CGFloat height = [heightList[0] floatValue]; rect.origin.y = rect.origin.y+ kPullHeight-height+64; [self.tableView scrollRectToVisible:rect animated:YES]; } [self stopHud]; }else if (actionTag == 2) { NSArray *temp = responsData[@"qaList"]; [temp enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { commentObjectVO *comment = setJsonDicToDataModel(obj, [commentObjectVO class]); [self.qaList addObject:comment]; }]; if (isCreat) { [self isCreatDataSource:sortIndex]; [self.tableView reloadData]; [self loadSuccess]; NSString *url = responsData[@"nextUrl"]; self.nextUrl = url; }else { [self loadSuccess]; NSString *url = responsData[@"nextUrl"]; self.nextUrl = url; [self otherDataSource:sortIndex nextUrl:url]; [self.tableView reloadData]; } } } - (void)remoteResponsFailed:(int)actionTag withMessage:(NSString *)message resultCode:(NSString *)code { ShowTextMessage(message); [self stopHud]; } // //- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView { // [self.tableView beginUpdates]; // [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:qaSecion] withRowAnimation:UITableViewRowAnimationNone]; // [self.tableView endUpdates]; //} #pragma mark - table delegate and datasource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return sectionNum; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { id obj = heightList[section]; if ([obj isKindOfClass:[NSString class]]) { return 1; }else { NSArray *array = obj; if (array.count ==0 ) { return 0; } return array.count; }} - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { id obj = heightList[indexPath.section]; if ([obj isKindOfClass:[NSString class]]) { return [obj floatValue]; }else { NSArray *array = obj; if (array.count == 0) { return 0; }else { return [array[indexPath.row] floatValue]; } } } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { id obj = self.dataList[section]; if ([obj isKindOfClass:[NSString class]]) { return 0; }else { NSArray *array = obj; if (array.count == 0) { return 0; }else { if ([array[0] isKindOfClass:[NSString class]]) { return 60; }else return 40; } } } - (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { id obj = self.dataList[section]; if ([obj isKindOfClass:[NSString class]]) { return nil; }else { NSArray *array = obj; if (array.count == 0) { return nil; }else { if ([array[0] isKindOfClass:[NSString class]]) { qaSecion = section; creatQaListHeaderView *view = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:creatQaListHeaderIdentifer]; view.isCreat = isCreat; view.sortIndex = [sortIndex integerValue]; view.delegate = self; return view; }else { if ([array[0] isKindOfClass:[listContObjectVO class]]) { relateHeaderView *view = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:relateHeaderIdentifer]; view.titleLable.text = @"相关新闻"; return view; }else { relateHeaderView *view = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:relateHeaderIdentifer]; view.titleLable.text = @"相关话题"; return view; } } } } } - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { id obj = self.dataList[indexPath.section]; if ([obj isKindOfClass:[NSString class]]) { if([obj isEqualToString:@"noData"]){//【需求】话题:用户页面,总提问数和回复数的显示(bug:4312) return [self returnNoDataCell:table cellForRowAtIndexPath:indexPath]; }else{ return [self returnDescCell:table cellForRowAtIndexPath:indexPath]; } }else { NSArray *array = obj; if ([array[indexPath.row] isKindOfClass:[commentObjectVO class]]) { commentObjectVO *commentBO = array[indexPath.row]; if ([commentBO.type intValue] == 2) { return [self returnCreatTopicAsk:table cellForRowAtIndexPath:indexPath]; }else { return [self returnTopicAnswerCell:table cellForRowAtIndexPath:indexPath]; } }else if([array[indexPath.row] isKindOfClass:[listContObjectVO class]]) { return [self returnRelateNewsCell:table cellForRowAtIndexPath:indexPath]; }else if([array[indexPath.row] isKindOfClass:[TopicInfoBO class]]) { return [self returnRelateTopicCell:table cellForRowAtIndexPath:indexPath]; }else { return [self returnQaNumCell:table cellForRowAtIndexPath:indexPath]; } } } - (UITableViewCell*)returnNoDataCell:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath {//【需求】话题:用户页面,总提问数和回复数的显示(bug:4312) static NSString *noDataCell = @"topicNoData cell"; topicNoDataCell *cell = [table dequeueReusableCellWithIdentifier:noDataCell]; if (nil == cell) { cell = [[topicNoDataCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:noDataCell]; } cell.topicDataDelegate = self; return cell; } - (UITableViewCell*)returnQaNumCell:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell* cell = [table dequeueReusableCellWithIdentifier:qaNumCellId]; if (nil == cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:qaNumCellId]; cell.backgroundColor = [UIColor clearColor]; cell.selectionStyle = UITableViewCellSelectionStyleNone; RTLabel *titleLabel = [[RTLabel alloc]initWithFrame:CGRectZero]; titleLabel.font = appFont(11, NO); titleLabel.backgroundColor = [UIColor clearColor]; titleLabel.textColor = [UIColor colorWithHexString:LINECOLOR]; titleLabel.textAlignment = RTTextAlignmentLeft; titleLabel.tag = 100; [cell.contentView addSubview:titleLabel]; } RTLabel *label = (RTLabel*)[cell.contentView viewWithTag:100]; label.frame = CGRectMake(padding, 15, tableWidht, CGRectGetHeight(cell.contentView.bounds)); id obj = self.dataList[indexPath.section]; if ([obj isKindOfClass:[NSArray class]]) { id str = obj[indexPath.row]; if ([str isKindOfClass:[NSString class]]) { label.text = str; } } return cell; } - (topicDescCell *)returnDescCell:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* descCellId = @"topicDesc cell"; topicDescCell* cell = (topicDescCell*)[table dequeueReusableCellWithIdentifier:descCellId]; if (nil == cell) { cell = [[topicDescCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:descCellId]; } cell.delegate = self; cell.padding = padding; cell.expand = isDescExpand; id obj = self.dataList[indexPath.section]; if ([obj isKindOfClass:[NSString class]]) { cell.topicDesc = obj; } return cell; } - (topicAskCell *)returnCreatTopicAsk:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* creatTopicAskID = @"creatTopicAsk cell"; topicAskCell* cell = (topicAskCell*)[table dequeueReusableCellWithIdentifier:creatTopicAskID]; if (nil == cell) { cell = [[topicAskCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:creatTopicAskID]; } cell.padding = padding; cell.topicAskCellDelegate = self; id obj = self.dataList[indexPath.section]; NSArray *array = obj; if ([array[indexPath.row] isKindOfClass:[commentObjectVO class]]) { cell.commentBO = array[indexPath.row]; BOOL isAskCreat = NO; if (self.isCreat && [sortIndex intValue] == 0) { isAskCreat = YES; } cell.isCreat = isAskCreat; } return cell; } - (topicAnswerCell *)returnTopicAnswerCell:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* topicAnswerCellID = @"topicAnswer cell"; topicAnswerCell* cell = (topicAnswerCell*)[table dequeueReusableCellWithIdentifier:topicAnswerCellID]; if (nil == cell) { cell = [[topicAnswerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:topicAnswerCellID]; } cell.padding = padding; cell.indexPath = indexPath; cell.delegate = self; id obj = self.dataList[indexPath.section]; NSArray *array = obj; if ([array[indexPath.row] isKindOfClass:[commentObjectVO class]]) { commentObjectVO *askBO = array[indexPath.row-1]; cell.commentBO = array[indexPath.row]; cell.askCommentBO = askBO; } return cell; } - (relateNewsCell *)returnRelateNewsCell:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* relateNewsCellID = @"relateNews cell"; relateNewsCell* cell = (relateNewsCell*)[table dequeueReusableCellWithIdentifier:relateNewsCellID]; if (nil == cell) { cell = [[relateNewsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:relateNewsCellID]; } cell.padding = padding; id obj = self.dataList[indexPath.section]; NSArray *array = obj; if ([array[indexPath.row] isKindOfClass:[listContObjectVO class]]) { cell.listBO = array[indexPath.row]; } return cell; } - (relateTopicCell *)returnRelateTopicCell:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* relateTopicCellID = @"relateTopic cell"; relateTopicCell* cell = (relateTopicCell*)[table dequeueReusableCellWithIdentifier:relateTopicCellID]; if (nil == cell) { cell = [[relateTopicCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:relateTopicCellID]; } cell.padding = padding; id obj = self.dataList[indexPath.section]; NSArray *array = obj; if ([array[indexPath.row] isKindOfClass:[TopicInfoBO class]]) { cell.topicInfo = array[indexPath.row]; } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; id obj = self.dataList[indexPath.section]; if (![obj isKindOfClass:[NSArray class]]) { return; } NSArray *array = obj; id data = array[indexPath.row]; if ([data isKindOfClass:[listContObjectVO class]]) { //跳入文章详情 pushContentWithListContentObject(self.navigationController, data); }else if ([data isKindOfClass:[commentObjectVO class]]) { commentObjectVO *comment = data; if ([comment.type intValue] == 2) { // if (comment.answerList.count == 0 && isCreat) { //直接回答 // 话题-待回复列表(创建者),回答提问成功后,按钮变成已回复,再点击应进入问答详情页;(bug:4748) // if(!comment.isAnswer && comment.answerList.count <=0 && isCreat){//直接回答 题主话题详情页:有用户自问自答,显示在待回复列表异常(bug:5593) //【倒退】话题题主页面,已回复tab,点击提问,跳转到回复页面,应该跳转到话题的问答详情页(bug:5718) 用sortIndex和isCreat判断是待回复还是已回复列表 if(!comment.isAnswer && isCreat && [sortIndex intValue] == 0){ if ([self.topicTableDelegate respondsToSelector:@selector(answerByCreatInTopic:)]) { if ([replyedNum intValue] == 0) { [MobClick event:@"37"]; } lastIndexPath = indexPath; [self.topicTableDelegate answerByCreatInTopic:comment]; } }else { //跳入问答详情页 [self gotoHotAskListHome:data]; } } }else if ([data isKindOfClass:[TopicInfoBO class]]) {//跳入问答详情 pushTopicPageWithTopicInfo(self.navigationController, data); } } - (void)reloadAskCellAfterAsking { if (!lastIndexPath) { return; } // topicAskCell *askCell = nil; UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:lastIndexPath]; if (![cell isKindOfClass:[topicAskCell class]]) { return; } // askCell = (topicAskCell*)cell; id obj = self.dataList[lastIndexPath.section]; NSArray *array = obj; if ([array[lastIndexPath.row] isKindOfClass:[commentObjectVO class]]) { commentObjectVO *data = array[lastIndexPath.row]; data.isAnswer = @"1"; NSMutableArray *temp = [NSMutableArray arrayWithArray:array]; [temp replaceObjectAtIndex:lastIndexPath.row withObject:data]; [self.dataList replaceObjectAtIndex:lastIndexPath.section withObject:temp]; [self.tableView reloadData]; } } #pragma mark - go to ask list //-(void)gotoHotAskListHome:(TopicInfoBO *)topic{ -(void)gotoHotAskListHome:(commentObjectVO *)comment{ if (!self.hotAskVC) { self.hotAskVC = [[hotAskListHomeController alloc]init]; self.hotAskVC.commentBO = comment; self.hotAskVC.commentOT = @"3"; self.hotAskVC.delegate = self; } self.hotAskVC.isNeedHold = YES; __weak typeof(self) Self = self; [self presentController:Self.hotAskVC animated:YES presentSize:hotAskListPopUpSize completion:^{ } dismiss:^{ if(!Self.hotAskVC.isNeedHold){ Self.hotAskVC = nil; } } tapHandler:^{ if (Self.hotAskVC.writeVC) { [Self.hotAskVC.writeVC closeKeyBoard]; } }]; } -(void)hotAskHomeToTopic:(TopicInfoBO *)topic user:(userBO *)user{ __weak typeof(self) Self = self; self.hotAskVC.isNeedHold = YES; [self.hotAskVC dismissControllerAnimated:YES completion:^{ if (!Self.hotAskVC.isNeedHold) { Self.hotAskVC = nil; } topicContentController *topicControllerVC = [[topicContentController alloc]init]; if (topic) { topicControllerVC.preTopicInfo = topic; topicControllerVC.creatUser = user; } [Self.navigationController pushViewController:topicControllerVC animated:YES]; }]; } -(void)gotoPersonInfo:(commentObjectVO *)comment{ self.hotAskVC.isNeedHold = YES; [self dismissControllerAnimated:YES completion:^{ otherPersonHomepageController *otherVC = [otherPersonHomepageController new]; otherVC.commentBo = comment; [self.navigationController pushViewController:otherVC animated:YES]; }]; } -(void)goAsk{ if ([self.topicTableDelegate respondsToSelector:@selector(topicTableToAsk)]) { [self.topicTableDelegate topicTableToAsk]; } } #pragma mark - cell delegate - (void)clickToExpand:(BOOL)isExpand { isDescExpand = isExpand; if (isExpand) { NSString *topicDesc = self.topicInfo.desc; CGFloat descHeight = heightForString(topicDesc, appFont(14, NO), tableWidht, NSLineBreakByWordWrapping)+15; descHeight = descHeight + 13 + 30; [heightList replaceObjectAtIndex:0 withObject:[NSString stringWithFormat:@"%f",descHeight]]; }else { NSString *topicDesc = self.topicInfo.desc; CGFloat descHeight = heightForString(topicDesc, appFont(14, NO), tableWidht, NSLineBreakByWordWrapping)+15; descHeight = 83 + 13 + 30; [heightList replaceObjectAtIndex:0 withObject:[NSString stringWithFormat:@"%f",descHeight]]; } // [self.tableView beginUpdates]; // [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone]; // [self.tableView endUpdates]; [self.tableView reloadData]; // [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES]; } - (void)clickToSortQaList:(NSString *)indexStr { sortIndex = indexStr; if (isCreat) { [self remoteAskForMyQaList:indexStr]; }else { [self remmoteAskForOtherQaList:indexStr]; } } - (void)hasPraisedAnswer:(NSIndexPath *)indexPath withCommentBO:(commentObjectVO *)commentBO { NSMutableArray *array = [NSMutableArray arrayWithArray:self.dataList[indexPath.section]]; [array replaceObjectAtIndex:indexPath.row withObject:commentBO]; [self.dataList replaceObjectAtIndex:indexPath.section withObject:array]; } - (void)commentBackForUser:(NSIndexPath *)indexPath withCommentBO:(commentObjectVO *)commentBO askBO:(commentObjectVO *)askBO{ if (!self.hotAskVC) { self.hotAskVC = [[hotAskListHomeController alloc]init]; self.hotAskVC.commentBO = askBO; self.hotAskVC.commentOT = @"3"; self.hotAskVC.delegate = self; } __weak typeof(self) Self = self; [self presentController:Self.hotAskVC animated:YES presentSize:hotAskListPopUpSize completion:^{ [Self.hotAskVC answerBackUser:commentBO closeHidden:YES]; } dismiss:^{ Self.hotAskVC = nil; } tapHandler:^{ if (Self.hotAskVC.writeVC) { [Self.hotAskVC.writeVC closeKeyBoard]; } }]; } #pragma mark - pull load method - (void)pullLoadMoreHander { if (!self.nextUrl) { TPLOG(@"数据有问题,无法获取新数据"); [self loadSuccess]; return; } [Remote doJsonAction:2 requestUrl:self.nextUrl parameter:nil delegate:self]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)refreshNumAfterAsk { UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:qaSecion]]; RTLabel *label = (RTLabel *)[cell.contentView viewWithTag:100]; // label.text = @"1000000000"; if (self.qaList.count > 0) { NSString *strString = [NSString stringWithFormat:@"共%d个提问,%@个回复",[self.topicInfo.waitReplyNum intValue] + [self.topicInfo.replyedNum intValue] +1,replayNum]; label.text = strString; }else { // NSString *strString = @""; // if ([self.topicInfo.waitReplyNum integerValue] <=0) { // strString = @"题主尚未开始回答"; // }else{ NSString *strString = [NSString stringWithFormat:@"共有%d个提问,题主尚未开始回答",[self.topicInfo.waitReplyNum intValue] + [self.topicInfo.replyedNum intValue]+1]; // } label.text = strString; } self.topicInfo.waitReplyNum = [NSString stringWithFormat:@"%d" , [self.topicInfo.waitReplyNum intValue] +1]; } //得到关注按钮的状态 -(BOOL) getAttentionStatus{ BOOL select = self.attentionBtn.selected; return select; } //改变关注按钮的状态 -(void) changeAttention{ self.attentionBtn.selected = YES; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end