170616
Posted zhen_zhen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了170616相关的知识,希望对你有一定的参考价值。
#import "PopularizaOfScience.h"
#import "polularScienceArticleDetails.h"
#import "RightIamgeviewSizeBtn.h"
#import "TTGTagCollectionView.h"
#import "TTGTextTagCollectionView.h"
@interface PopularizaOfScience ()<UITableViewDataSource,UITableViewDelegate,TTGTextTagCollectionViewDelegate,UIGestureRecognizerDelegate>
{ int number;
UIImageView *imagershuju;
UILabel *tiwuxianLab;
UICollectionView *_collectionView;
NSMutableArray *selectM;
UILabel *labelFontColor;
UIImageView *imageBim ;
NSMutableArray *tabMut;
NSMutableArray *signMut;
NSString *signStr;
BOOL isRequest;
NSInteger jiuNum ;
NSMutableArray *namesArr;
NSString *totalPage;
//gzz0614 yangzhuan
int pageNumber;
int page; //就是那个 number
int tempPage;
int yz;
NSIndexPath *preIndexpath;
BOOL isOneTag;//gzz0822
NSIndexPath *zeroIndexpath;
UIView *lineview;
BOOL isNew;//最新还是最热
BOOL isSelectContent;//是否选中筛选按钮
BOOL isSeletSureBtn;//是否点击了确定按钮
}
@property (nonatomic,strong) UITableView *PopulaTableview;
@property (nonatomic,strong) NSMutableArray *GardenPlotArray;
@property(nonatomic,strong)NSMutableArray *tempArray;//yang
/*最新最热*/
@property (nonatomic, strong) RightIamgeviewSizeBtn *hotAndNewBtn;
/*筛选*/
@property (nonatomic, strong) RightIamgeviewSizeBtn *selectContentBtn;
/*标签*/
@property (strong, nonatomic) TTGTextTagCollectionView *textTagCollectionView1;
@property (strong, nonatomic) NSArray *tags;
/*盛放选中数据 点击确定键都放入里面*/
@property (nonatomic, strong) NSMutableArray *dataSeletMarr;
/*盛放选中数据 有没有点击确定键都放入里面*/
@property (nonatomic, strong) NSMutableArray *dataSeletMarrNoSureBtn;
/*出现隐藏标签的bool*/
@property (nonatomic, assign) BOOL isHidden;
@property(nonatomic,strong)UIView *bgView;
@end
@implementation PopularizaOfScience
-(void)viewWillAppear:(BOOL)animated
{
//gzz170615 没有从全局搜索进来是怎样的 从全局搜索进来又是怎样的
[super viewWillAppear:animated];
if ([_allSearchValueStr isEqualToString:@"<null>"] || [_allSearchValueStr isEqualToString:@"null"] || [_allSearchValueStr isEqualToString:@"(null)"] || _allSearchValueStr.length <= 0) {
}else{
//默认是最新 还是最热
}
[self POScrienceRequest];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"科普园地";
self.view.backgroundColor=[UIColor whiteColor];
number=1;
isOneTag = YES;
tempPage = 1;
isNew = YES;
isSelectContent = NO;
_isHidden = YES;
isSeletSureBtn = NO;
_GardenPlotArray = [NSMutableArray array];
_tempArray = [[NSMutableArray alloc]init];
selectM = [NSMutableArray array];
namesArr = [NSMutableArray array];
jiuNum = 0 ;
signStr = @"";
tabMut = [NSMutableArray array];
signMut = [NSMutableArray array];
_dataSeletMarr = [NSMutableArray array];
_dataSeletMarrNoSureBtn = [NSMutableArray array];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"NavBack"] originalImage] style:UIBarButtonItemStylePlain target:self action:@selector(backClick)];
self.navigationItem.leftBarButtonItem=backItem;
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
[self Popuofview];
// [self tagsUI];
}
//下拉刷新
- (void)Downrefresh{
__weak PopularizaOfScience *puad = self;
[puad.PopulaTableview addHeaderWithCallback:^{
[puad.GardenPlotArray removeAllObjects];
number=1;
[puad POScrienceRequest];
[puad.PopulaTableview headerEndRefreshing];
}];
}
//上拉加载
- (void)haderwith
{
__weak PopularizaOfScience *pudb = self;
[pudb.PopulaTableview addFooterWithCallback:^{
number++;
tempPage = number + 2;
[pudb POScrienceRequest];
[pudb.PopulaTableview footerEndRefreshing];
}];
}
#pragma mark UI界面
- (void)Popuofview{
_hotAndNewBtn = [[RightIamgeviewSizeBtn alloc]initWithFrame:CGRectMake(0, 0+64, 100, 45)];
[self.view addSubview:_hotAndNewBtn];
[_hotAndNewBtn setTitle:@"最新" forState:0];
[_hotAndNewBtn setTitleColor:JISECOLOR forState:0];
_hotAndNewBtn.titleLabel.font = SYSTEMFONT(16.0);
[_hotAndNewBtn setImage:[[UIImage imageNamed:@"newSimage"] originalImage] forState:0];
_hotAndNewBtn.backgroundColor = [UIColor whiteColor];
[_hotAndNewBtn sizeToFit];
_hotAndNewBtn.frame = CGRectMake((SCREEN_WIDTH/2-_hotAndNewBtn.width)/2, _hotAndNewBtn.y, _hotAndNewBtn.width,45);
UIView *bgNewAndHot = [UIView createViewWithFrame:CGRectMake(0, 0+64, SCREEN_WIDTH, 45) bgColor:[UIColor clearColor]];
[self.view addSubview:bgNewAndHot];
bgNewAndHot.userInteractionEnabled = YES;
UITapGestureRecognizer *ges = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(newAndHotClickPop)];
[bgNewAndHot addGestureRecognizer:ges];
UIView *verticalLine = [UIView createViewWithFrame:CGRectMake(SCREEN_WIDTH/2, 13.5+64, 1, 18) bgColor:bgLineColor];
[self.view addSubview:verticalLine];
_selectContentBtn = [[RightIamgeviewSizeBtn alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2+1, 0+64, 100, 45)];
[self.view addSubview:_selectContentBtn];
[_selectContentBtn setTitle:@"筛选" forState:0];
[_selectContentBtn setTitleColor:[UIColor lightGrayColor] forState:0];
_selectContentBtn.titleLabel.font = SYSTEMFONT(16.0);
[_selectContentBtn setImage:[[UIImage imageNamed:@"shaiSMoren"] originalImage] forState:0];
_selectContentBtn.backgroundColor = [UIColor whiteColor];
[_selectContentBtn sizeToFit];
_selectContentBtn.frame = CGRectMake(SCREEN_WIDTH/2+1+(SCREEN_WIDTH/2-_selectContentBtn.width)/2, _selectContentBtn.y, _selectContentBtn.width,45);
UIView *bgselect = [UIView createViewWithFrame:CGRectMake(SCREEN_WIDTH/2+1, 0+64, SCREEN_WIDTH, 45) bgColor:[UIColor clearColor]];
[self.view addSubview:bgselect];
bgselect.userInteractionEnabled = YES;
UITapGestureRecognizer *gess = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(selectContentClick)];
[bgselect addGestureRecognizer:gess];
UIView *horizLine = [UIView createViewWithFrame:CGRectMake(0, CGRectGetMaxY(_hotAndNewBtn.frame), SCREEN_WIDTH, 10) bgColor:bgLineColor];
[self.view addSubview:horizLine];
self.PopulaTableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+45+10, SCREEN_WIDTH, SCREEN_HEIGHT-45-10-64)];
_PopulaTableview.showsVerticalScrollIndicator = YES;
_PopulaTableview.backgroundColor = [UIColor whiteColor] ;
self.PopulaTableview.delegate = self;
self.PopulaTableview.dataSource = self;
_PopulaTableview.tableFooterView=[[UIView alloc]init];
[self.view addSubview:self.PopulaTableview];
imagershuju = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-ImagerWuWidth/2, SCREEN_HEIGHT/2-ImagerWuheight/2, ImagerWuWidth, ImagerWuheight)];
imagershuju.image = [UIImage imageNamed:@"zanwushuju2"];
imagershuju.hidden = YES;
[self.view addSubview:imagershuju];
tiwuxianLab = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-TishiLabwidth/2, CGRectGetMaxY(imagershuju.frame), TishiLabwidth, 30)];
tiwuxianLab.text = @"暂无科普文章";
tiwuxianLab.textAlignment = YES;
tiwuxianLab.textColor = RGB(204, 204, 204);//RGB(188, 188, 188);
tiwuxianLab.hidden = YES;
tiwuxianLab.font = SYSTEMFONT(TishiLabFont);
[self.view addSubview:tiwuxianLab];
[self haderwith];
[self Downrefresh];
}
#pragma mark 最新最热
- (void)newAndHotClickPop{
isNew = !isNew;
if (!isNew) {
[_hotAndNewBtn setTitle:@"最热" forState:0];
[_hotAndNewBtn setImage:[[UIImage imageNamed:@"hotimageS"] originalImage] forState:0];
}else{
[_hotAndNewBtn setTitle:@"最新" forState:0];
[_hotAndNewBtn setImage:[[UIImage imageNamed:@"newSimage"] originalImage] forState:0];
}
MClogFunc
}
#pragma mark selectContentClick筛选
- (void)selectContentClick{
//移除选中的数据
[_dataSeletMarrNoSureBtn removeAllObjects];
isSelectContent = !isSelectContent;
if (isSelectContent) {
[_selectContentBtn setImage:[[UIImage imageNamed:@"shaiSLight"] originalImage] forState:0];
[_selectContentBtn setTitleColor:JISECOLOR forState:0];
[self tagsUI];
}else{
if (_dataSeletMarr.count>0 && isSeletSureBtn) {
[_selectContentBtn setImage:[[UIImage imageNamed:@"shaiSLight"] originalImage] forState:0];
[_selectContentBtn setTitleColor:JISECOLOR forState:0];
}else{
[_selectContentBtn setImage:[[UIImage imageNamed:@"shaiSMoren"] originalImage] forState:0];
[_selectContentBtn setTitleColor:[UIColor lightGrayColor] forState:0];
}
[self.view endEditing:YES];
_isHidden = YES;
[UIView animateWithDuration:0.25 animations:^{
_bgView.hidden = YES;
_bgView.alpha = 0;
} completion:^(BOOL finished) {
[_textTagCollectionView1 removeFromSuperview];
[_bgView removeFromSuperview];
}];
}
}
#pragma mark 标签出来的界面
- (void)tagsUI{
if (_isHidden) {
_isHidden=NO;
_bgView = [UIView createViewWithFrame:CGRectMake(0, 64+55, SCREEN_WIDTH, SCREEN_HEIGHT-55-64) bgColor:[UIColor whiteColor]];//[
[self.view addSubview:_bgView];
_bgView.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sureBtnClick)];
tapGesture.delegate = self;
//设置成NO表示当前控件响应后会传播到其他控件上,默认为YES。
tapGesture.cancelsTouchesInView = NO;
[_bgView addGestureRecognizer:tapGesture];
_textTagCollectionView1 = [[TTGTextTagCollectionView alloc]init];
[_bgView addSubview:_textTagCollectionView1];
// _textTagCollectionView1.hidden = YES;
_textTagCollectionView1.selectionLimit = 3;
_textTagCollectionView1.frame = CGRectMake(10, 20, self.view.frame.size.width-20, SCREEN_HEIGHT-64-55-45-20);
_textTagCollectionView1.backgroundColor = [UIColor whiteColor];
_tags = @[
@"乙型肝炎", @"肝炎", @"乙型肝炎", @"炎", @"乙型肝炎", @"乙型肝炎",
@"乙型肝炎", @"乙型炎",@"肝炎", @"乙型炎", @"乙型肝炎", @"乙型肝炎", @"乙型肝炎", @"乙型肝炎",
@"乙型肝炎", @"乙型炎的地方",@"乙型肝炎", @"肝炎", @"乙型肝炎", @"乙型肝炎", @"乙型肝炎", @"乙炎",
@"乙型肝炎", @"乙型肝炎", @"乙型肝炎", @"肝炎", @"乙型肝炎", @"炎", @"乙型肝炎", @"乙型肝炎",
@"乙型肝炎", @"乙型炎", @"乙型炎", @"乙型肝炎", @"乙型肝炎", @"乙型肝炎", @"乙型肝炎",
@"乙型肝炎", @"乙型炎的地方",@"乙型肝炎", @"肝炎", @"乙型肝炎", @"乙型肝炎", @"乙型肝炎", @"乙炎",
@"乙型肝炎", @"乙型肝炎",@"乙型肝炎", @"乙型炎",@"肝炎", @"乙型炎", @"乙型肝炎", @"乙型肝炎", @"乙型肝炎", @"乙型肝炎",
@"乙型肝炎", @"乙型炎的地方",@"乙型肝炎", @"肝炎", @"乙型肝炎", @"乙型肝炎", @"乙型肝炎", @"乙炎",
@"乙型肝炎", @"乙型肝炎"
];
_textTagCollectionView1.delegate = self;
_textTagCollectionView1.showsVerticalScrollIndicator = NO;
// _textTagCollectionView1.contentSize = CGSizeMake(65, 20);
TTGTextTagConfig *config = _textTagCollectionView1.defaultConfig;
config.tagTextFont = [UIFont boldSystemFontOfSize:12.0f];
//文本的颜色
config.tagTextColor = QIANBLACKCOLOR;
//选中的样色
config.tagSelectedTextColor = JISECOLOR;
config.tagBackgroundColor = [UIColor clearColor];
config.tagSelectedBackgroundColor = [UIColor clearColor];
//水平竖直间距
if (SCREEN_WIDTH == 320) {
_textTagCollectionView1.horizontalSpacing = 12.0;
_textTagCollectionView1.verticalSpacing = 12.0;
}else if (SCREEN_WIDTH == 375 ){
_textTagCollectionView1.horizontalSpacing = 23.0;
_textTagCollectionView1.verticalSpacing = 15.0;
}else if (SCREEN_WIDTH == 414 ){
_textTagCollectionView1.horizontalSpacing = 30.0;
_textTagCollectionView1.verticalSpacing = 20.0;
}else{
//iPhone
}
//外围包裹
config.tagBorderColor = QIANBLACKCOLOR;
config.tagSelectedBorderColor = JISECOLOR;
config.tagBorderWidth = 1;
config.tagSelectedBorderWidth = 1;
//阴影
config.tagShadowColor = [UIColor whiteColor];
config.tagShadowOffset = CGSizeMake(0, 0);
config.tagShadowOpacity = 0.0f;
config.tagShadowRadius = 0.0f;
//裁剪
config.tagCornerRadius = 10.0;
config.tagSelectedCornerRadius = 10.0;
//扩展宽高
config.tagExtraSpace = CGSizeMake(10, 10);
[_textTagCollectionView1 addTags:_tags];
_textTagCollectionView1.alignment = 0;
if (isSeletSureBtn) {
for (int i = 0; i<_dataSeletMarr.count; i++) {
NSUInteger index = [[_dataSeletMarr objectAtIndex:i] integerValue];
[_textTagCollectionView1 setTagAtIndex:index selected:YES];
}
[_dataSeletMarrNoSureBtn addObjectsFromArray:_dataSeletMarr];
}else{
isSeletSureBtn = NO;
[_dataSeletMarr removeAllObjects];
}
[_textTagCollectionView1 reload];
WEAKSELFS
UIButton *sureBtn = [UIButton createTypeTwoBtnFrame:CGRectMake(10, _bgView.height-45, SCREEN_WIDTH-20, 35) title:@"确定" bgImageName:@"d" titleColor:[UIColor whiteColor] bgColor:JISECOLOR titleLabelFont:20 action:^(UIButton *button) {
isSeletSureBtn = YES;
[weakSelf sureBtnClick];
[_dataSeletMarr removeAllObjects];
[_dataSeletMarr addObjectsFromArray:_dataSeletMarrNoSureBtn];
//移除选中的数据
[_dataSeletMarrNoSureBtn removeAllObjects];
isSelectContent = !isSelectContent;
if (isSelectContent) {
[_selectContentBtn setImage:[[UIImage imageNamed:@"shaiSLight"] originalImage] forState:0];
[_selectContentBtn setTitleColor:JISECOLOR forState:0];
}else{
if (_dataSeletMarr.count>0) {
[_selectContentBtn setImage:[[UIImage imageNamed:@"shaiSLight"] originalImage] forState:0];
[_selectContentBtn setTitleColor:JISECOLOR forState:0];
}else{
[_selectContentBtn setImage:[[UIImage imageNamed:@"shaiSMoren"] originalImage] forState:0];
[_selectContentBtn setTitleColor:[UIColor lightGrayColor] forState:0];
}
}
}];
sureBtn.layer.cornerRadius = 5;
sureBtn.layer.masksToBounds = YES;
[_bgView addSubview:sureBtn];
}
}
#pragma mark 确定
-(void)sureBtnClick{//gzz0207
[self.view endEditing:YES];
_isHidden = YES;
[UIView animateWithDuration:0.25 animations:^{
_bgView.hidden = YES;
_bgView.alpha = 0;
} completion:^(BOOL finished) {
[_textTagCollectionView1 removeFromSuperview];
[_bgView removeFromSuperview];
}];
}
#pragma mark - TTGTextTagCollectionViewDelegate
- (void)textTagCollectionView:(TTGTextTagCollectionView *)textTagCollectionView didTapTag:(NSString *)tagText atIndex:(NSUInteger)index selected:(BOOL)selected {
NSLog(@"%@----所选中的tag-",textTagCollectionView.allSelectedTags);
NSString *tagsindexstr = [NSString stringWithFormat:@"%zd",index];
if (selected == 1) {
[_dataSeletMarrNoSureBtn addObject:tagsindexstr];
}else {
for (int i =0 ; i<_dataSeletMarrNoSureBtn.count; i++) {
if ([[_dataSeletMarrNoSureBtn objectAtIndex:i] isEqualToString:tagsindexstr]) {
[_dataSeletMarrNoSureBtn removeObjectAtIndex:i];
}
}
}
NSLog(@"---盛放的数据-%@-",_dataSeletMarr);
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 80+8;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (_GardenPlotArray.count>0) {
return _GardenPlotArray.count;
}else{
return 0;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *strint = @"cellKepuGarden";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strint];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strint];
}
else{//gzz170407
for (UIView *view in cell.contentView.subviews) {
[view removeFromSuperview];
}
}
if (_GardenPlotArray.count>0) {
NSDictionary *dic = [DicRemove clearErrorDataZanwu:_GardenPlotArray[indexPath.row]];
UIImageView *imagevview = [[UIImageView alloc]initWithFrame:CGRectMake(10, 6+4, 102, 68)];
NSString *imagess=[NSString stringWithFormat:@"%@",dic[@"imgPath"]];
NSString *imagename=[NSString stringWithFormat:@"%@%@",ImageUrl,imagess];
[imagevview sd_setImageWithURL:[NSURL URLWithString:imagename] placeholderImage:[UIImage imageNamed:@"contentMren"]];//gzz0919h
[cell.contentView addSubview:imagevview];
//gzz170213
UILabel* firstLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(imagevview.frame)+10,10,SCREEN_WIDTH-102-30,16)];//gzz0927
firstLabel.backgroundColor = [UIColor clearColor];
firstLabel.textColor = [UIColor blackColor];
firstLabel.numberOfLines=2;
firstLabel.font = [UIFont systemFontOfSize:16];
[cell.contentView addSubview:firstLabel];
NSString *summary=[dic objectForKey:@"topic"];
firstLabel.text=summary;
[firstLabel sizeToFit];
UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imagevview.frame)+10, 65,42, 14)]; //时间gzz0927
timeLabel.backgroundColor = [UIColor clearColor];
timeLabel.textColor = [UIColor grayColor];
timeLabel.font = [UIFont systemFontOfSize:12];
[cell.contentView addSubview:timeLabel];
NSString *timestr=[NSString stringWithFormat:@"%@", [dic objectForKey:@"modifyDate"]];
timestr=[timestr substringToIndex:10];
timeLabel.font=SYSTEMFONT(12);
timeLabel.textAlignment=NSTextAlignmentLeft;
timestr = [timestr substringWithRange:NSMakeRange(5, 5)];
timeLabel.text = timestr;
//总的view
UIView *coverView = [[UIView alloc]init];
coverView.frame = CGRectMake(SCREEN_WIDTH-120-10, 63, 120, 14);
coverView.backgroundColor = [UIColor whiteColor];
coverView.centerY = timeLabel.centerY;
[cell.contentView addSubview:coverView];
#pragma mark 图片+阅读量
UIImageView *readNumImageview = [[UIImageView alloc]init];
readNumImageview.frame = CGRectMake(0, 0, 14, 14);
readNumImageview.image = [UIImage imageNamed:@"read_news"];
[coverView addSubview:readNumImageview];
NSString *readStr=[NSString stringWithFormat:@"%@", [dic objectForKey:@"readnum"]];
NSString *readDa = readStr;
if (readStr.length>=5) {
NSInteger redNum = [readStr integerValue];
NSString *one,*two;
NSInteger onee = redNum/10000;
one = [NSString stringWithFormat:@"%zd",onee];
NSInteger twoo = redNum%10000;
twoo = twoo/1000;
two = [NSString stringWithFormat:@"%zd",twoo];
if (one.length>1) {
readDa=[NSString stringWithFormat:@"%@万",one];
}else{
readDa=[NSString stringWithFormat:@"%@.%@万",one,two];
}
}else{
readDa=[NSString stringWithFormat:@"%@", [dic objectForKey:@"readnum"]];
}
UILabel *readLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(readNumImageview.frame)+5, 0, 32, 14)];
[coverView addSubview:readLabel];
readLabel.backgroundColor = [UIColor clearColor];
readLabel.text = readDa;
readLabel.textAlignment = NSTextAlignmentLeft;
readLabel.textColor = [UIColor grayColor];
readLabel.font = [UIFont systemFontOfSize:12];
readLabel.centerY = readNumImageview.centerY;
#pragma mark 图片+点赞
UIImageView *agreeImageview = [[UIImageView alloc]init];
agreeImageview.frame = CGRectMake(CGRectGetMaxX(readLabel.frame)+5, 0, 14, 14);
agreeImageview.image = [UIImage imageNamed:@"agree_news"];
[coverView addSubview:agreeImageview];
NSString *agreeStr=[NSString stringWithFormat:@"%@", [dic objectForKey:@"agreenum"]];
NSString *agreeDa = agreeStr;
if (agreeDa.length>=5) {
NSInteger redNum = [agreeDa integerValue];
NSString *one,*two;
NSInteger onee = redNum/10000;
one = [NSString stringWithFormat:@"%zd",onee];
NSInteger twoo = redNum%10000;
twoo = twoo/1000;
two = [NSString stringWithFormat:@"%zd",twoo];
if (one.length>1) {
agreeDa=[NSString stringWithFormat:@"%@万",one];
}else{
agreeDa=[NSString stringWithFormat:@"%@.%@万",one,two];
}
}else{
agreeDa=[NSString stringWithFormat:@"%@", [dic objectForKey:@"agreenum"]];
}
UILabel *agreeLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(agreeImageview.frame)+5, 0, 32, 14)];
[coverView addSubview:agreeLabel];
agreeLabel.backgroundColor = [UIColor clearColor];
agreeLabel.text = agreeDa;
agreeLabel.textAlignment = NSTextAlignmentLeft;
agreeLabel.textColor = [UIColor grayColor];
agreeLabel.font = [UIFont systemFontOfSize:12];
agreeLabel.centerY = agreeImageview.centerY;
CGFloat wwww = 14+5+32+5+14+5+32;
coverView.frame = CGRectMake(SCREEN_WIDTH-wwww-10, coverView.y, wwww, 14);
} return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (_GardenPlotArray.count>0) {//gzz0909
[self readRequestKe:indexPath.row];
}
}
#pragma mark 内容请求
- (void) POScrienceRequest{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];//gzz0617af
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain",@"text/json",@"application/json", nil];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *Srurl = [NSString stringWithFormat:@"%@polularScienceArticleListByTab",Public_URL];//polularScienceArticleTabList
NSMutableDictionary *dicm = [NSMutableDictionary dictionary];
NSString * str ;
if (tempPage>=number) {
str = [NSString stringWithFormat:@"%d",number];
}else{
str = [NSString stringWithFormat:@"%d",tempPage];
}
dicm[@"page"]= str;
dicm[@"type"] = signStr;
[manager POST: Srurl parameters:dicm progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSMutableDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
NSString *coder = [NSString stringWithFormat:@"%@",dic[@"code"]];
NSDictionary *dicc =[DicRemove clearErrorData11a:dic];
if ([coder isEqualToString:@"1"]) {
NSArray * arr = [dicc objectForKey:@"data"];
if (number >= 2) {
if (tempPage>number) {
[_GardenPlotArray addObjectsFromArray:arr];//gzz0613
}else{
_tempArray = [[NSMutableArray alloc]init];
[_tempArray addObjectsFromArray:arr];//gzz0613
NSRange range8 = NSMakeRange(10*(tempPage-1), _tempArray.count);
[_GardenPlotArray replaceObjectsInRange:range8 withObjectsFromArray:_tempArray];
}
[_PopulaTableview reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
else{
_GardenPlotArray = [[NSMutableArray alloc]init];
if (arr.count>0) {
[_GardenPlotArray removeAllObjects];
[_GardenPlotArray addObjectsFromArray:dicc[@"data"]];//gzz0613
[_PopulaTableview reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}else{
[_PopulaTableview reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
}
}else{
[self showHint:[dicc objectForKey:@"message"]];
}
if (_GardenPlotArray.count>0) {
imagershuju.hidden = YES;
tiwuxianLab.hidden = YES;
_PopulaTableview.backgroundColor = WHITECOLORS;
// _collectionView.backgroundColor = WHITECOLORS;//RGB(206, 248, 246);
lineview.hidden = NO;
}else{
imagershuju.hidden = NO;
tiwuxianLab.hidden = NO;
if (tabMut.count <=0) {
lineview.hidden = YES;
}
}
[_PopulaTableview reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
if (_GardenPlotArray.count>0) {
imagershuju.hidden = YES;
tiwuxianLab.hidden = YES;
}else{
imagershuju.hidden = NO;
tiwuxianLab.hidden = NO;
lineview.hidden = YES;
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
#pragma mark 点击 阅读量加一的接口
-(void)readRequestKe:(NSInteger)iindex {
yz = (int)iindex/10+1;
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];//gzz0617af
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain",@"text/json",@"application/json", nil];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *Strurl = [NSString stringWithFormat:@"%@read",Public_URL];
Dlpontlerexple *dlp =[Dlpontlerexple shareIndence];
NSMutableDictionary *dicer = [NSMutableDictionary dictionary];
dicer[@"type"] =[NSString stringWithFormat:@"%d",2];
dicer[@"user_uuid"] = dlp.uuidstring;
NSDictionary *dicer11dd = [DicRemove clearErrorData11a:[_GardenPlotArray objectAtIndex:iindex]];//gzz0406
dicer[@"news_article_uuid"] = [NSString stringWithFormat:@"%@",dicer11dd[@"uuid"]];
[manager POST: Strurl parameters:dicer progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
NSString *codee=[NSString stringWithFormat:@"%@",dic[@"code"]];
if ([codee isEqualToString:@"1"]) {
NSString *isAgree = [NSString stringWithFormat:@"%@",dic[@"isAgree"]];
if (_GardenPlotArray.count>0) {
tempPage = yz;
polularScienceArticleDetails *news=[[polularScienceArticleDetails alloc]init];
NSDictionary *dicer11 = [DicRemove clearErrorData11a:[_GardenPlotArray objectAtIndex:iindex]];
news.PoluDiction = dicer11;
news.kepuUUID = [NSString stringWithFormat:@"%@",dicer11[@"uuid"]] ;
news.kepureadnum =[NSString stringWithFormat:@"%@",dicer11[@"readnum"]] ;
news.kepuAgree = isAgree;
news.kepuAgreenum =[NSString stringWithFormat:@"%@",dicer11[@"agreenum"]] ;
news.hidesBottomBarWhenPushed=YES;
[self.navigationController pushViewController:news animated:YES];
}
}else{
[self showHint:@"科普详情查询失败!"];
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self showHint:@"请求数据失败!"];
}];
}
- (void)backClick
{
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark 接口统一用PPNetworkHelper
-(void)hotAndNewRequest{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
NSString *Srurl = [NSString stringWithFormat:@"%@retrieveUser",Public_PING];
Dlpontlerexple *dlop = [Dlpontlerexple shareIndence];
NSMutableDictionary *dicm = [NSMutableDictionary dictionary];
dicm[@"user_uuid"] = dlop.uuidstring;
[PPNetworkHelper setRequestTimeoutInterval:15.0];
[PPNetworkHelper POST:Srurl parameters:dicm success:^(id responseObject) {
// NSMutableDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:responseObject];
if ([dic count]>0) {
}else{
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
} failure:^(NSError *error) {
if (error.code == -1001) {
[self showHint:@"请求超时"];
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
以上是关于170616的主要内容,如果未能解决你的问题,请参考以下文章