|
//
// myAnswersController.m
// ThePaperHD
//
// Created by scar1900 on 15/3/30.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "myAnswersController.h"
@interface myAnswersController ()<hotAskListHomeDelegate> {
UIView *_noDataBack;
}
@end
@implementation myAnswersController
@synthesize qaList = _qaList;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (UIView*)noDataBack {
if (!_noDataBack) {
_noDataBack = [[UIView alloc]initWithFrame:CGRectMake(0,
0,
myAskCenterPopSize.width,
CGRectGetHeight(self.view.bounds))];
_noDataBack.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_noDataBack.hidden = YES;
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(80, 350/2, 990/2, 20)];
label.textColor = [UIColor colorWithHexString:TextGray];
label.font = appFont(20, NO);
label.textAlignment = NSTextAlignmentLeft;
label.text = @"你能回答别人提出的问题?去分享你的知识和见解吧。";
[_noDataBack addSubview:label];
}
return _noDataBack;
}
- (void)setQaList:(NSMutableArray *)list {
_qaList = list;
if ([self checkIfNoData:list]) {
return;
}
self.qaDataSource = [NSMutableArray array];
self.qaHeightArray = [NSMutableArray array];
[self.qaList enumerateObjectsUsingBlock:^(commentObjectVO* obj, NSUInteger idx, BOOL *stop) {
if ([obj.type intValue] == 2) {
[self.qaDataSource addObject:obj];
CGFloat titleHeight = 50+returnTextHeightWithRTLabel(obj.content,930/2, appFont(15, NO),10)+15; //(姓名+内容高度+空行)
[self.qaHeightArray addObject:[NSString stringWithFormat:@"%f",titleHeight]];
}else {
[self.qaDataSource addObject:obj];
CGFloat contentHeight = 50+15; //提问者姓名+空行
CGFloat answerContent = returnTextHeightWithRTLabel(obj.content, messagePopSize.width-30, appFont(15, NO),10)>100?100+30:returnTextHeightWithRTLabel(obj.content, messagePopSize.width-30, appFont(15, NO),10);
contentHeight = contentHeight + answerContent+10;
if (obj.quoteInfo && obj.quoteInfo.allKeys.count>0) {//假如引用信息(盖楼)
contentHeight = contentHeight + 190/2;
}
[self.qaHeightArray addObject:[NSString stringWithFormat:@"%f",contentHeight]];
}
}];
[self.tableView reloadData];
}
- (void)pullRefreshHandler {
NSDictionary *dic = @{@"ctype":@(3)};
[Remote doJsonAction:1
requestUrl:myQaListURL
parameter:dic
delegate:self];
}
//-(void)gotoUserInfo:(commentObjectVO *)comment{
// if ([self.myAsksDelegate respondsToSelector:@selector(gotoUserGambit:)]) {
// [self.myAsksDelegate gotoUserGambit:comment];
// }
//}
#pragma mark - remote handler
- (void)remoteResponsSuccess:(int)actionTag withResponsData:(id)responsData {
if (actionTag == 1) {
NSArray *qaTempList = responsData[@"qaList"];
NSMutableArray *qaArray = [NSMutableArray array];
[qaTempList enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
commentObjectVO *commentBO = setJsonDicToDataModel(obj, [commentObjectVO class]);
commentObjectVO *askBO = setJsonDicToDataModel(commentBO.parentInfo, [commentObjectVO class]);
[qaArray addObject:askBO];
[qaArray addObject:commentBO];
}];
self.qaList = qaArray;
NSString *url = responsData[@"nextUrl"];
self.nextUrl = url;
[self endRefresh];
}else {
NSArray *qaTempList = responsData[@"qaList"];
NSMutableArray *qaArray = [NSMutableArray arrayWithArray:self.qaList];
[qaTempList enumerateObjectsUsingBlock:^(NSDictionary* obj, NSUInteger idx, BOOL *stop) {
commentObjectVO *commentBO = setJsonDicToDataModel(obj, [commentObjectVO class]);
commentObjectVO *askBO = setJsonDicToDataModel(commentBO.parentInfo, [commentObjectVO class]);
[qaArray addObject:askBO];
[qaArray addObject:commentBO];
}];
self.qaList = [NSMutableArray arrayWithArray:qaArray];
[self loadSuccess];
NSString *url = responsData[@"nextUrl"];
self.nextUrl = url;
}
}
-(void)goToOriginContent:(objInfoBO *)commentBO presentedController:(TPHttpController *)presentedController{
NSDictionary *dic = @{@"data":commentBO};
[[NSNotificationCenter defaultCenter] postNotificationName:PUSHTODETAILCONTENT object:nil userInfo:dic];
}
//-(void)gotoUserInfo:(commentObjectVO *)comment{
//
//}
//
//-(void)gotoPersonInfo:(commentObjectVO *)comment{
//
//}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#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
|