科普园地

//

//  PopularizaOfScience.m

//  Patient

//

//  Created by y on 15/11/4.

//  Copyright © 2015年 ShangYu. All rights reserved.

//

#import "PopularizaOfScience.h"

#import "polularScienceArticleDetails.h"

#import "CustomFlowLayout.h"

//#define WIDTHCOLLECTION (SCREEN_WIDTH-18-15)/4

@interface PopularizaOfScience ()<UITableViewDataSource,UITableViewDelegate,UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>

{

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  yangzhuang

int pageNumber;

int page;  //就是那个 number

int tempPage;

int yz;

//gzz0802

NSIndexPath *preIndexpath;

BOOL isOneTag;//gzz0822

NSIndexPath *zeroIndexpath;

UIView *lineview;

}

@property (nonatomic,strong) UITableView *PopulaTableview;

@property (nonatomic,strong) NSMutableArray *GardenPlotArray;

@property(nonatomic,strong)NSMutableArray *tempArray;//yang

@end

@implementation PopularizaOfScience

-(void)viewWillAppear:(BOOL)animated

{

[super viewWillAppear:animated];

[self POScrienceRequest];

}

- (void)viewDidLoad {

[super viewDidLoad];

self.title = @"科普园地";

self.view.backgroundColor=[UIColor whiteColor];

number=1;

isOneTag = YES;

tempPage = 1;

_GardenPlotArray = [NSMutableArray array];

_tempArray = [[NSMutableArray alloc]init];

selectM = [NSMutableArray array];

namesArr = [NSMutableArray array];

jiuNum = 0 ;

signStr = @"";

tabMut = [NSMutableArray array];

signMut = [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;

UIImageView *imageBim1 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"jianbian5"]];

imageBim1.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);

imageBim = imageBim1;

[self.view addSubview:imageBim1];

[self SignalUI];

[self  signRequest];

[self Popuofview];

}

//下拉刷新

- (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

{

self.PopulaTableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+40, SCREEN_WIDTH, SCREEN_HEIGHT-40-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:@"zanwushuju1"];

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];

}

-(void)SignalUI{

CustomFlowLayout *flowLayOut = [[CustomFlowLayout alloc]init];

flowLayOut.sectionInset = UIEdgeInsetsMake(11, 20, 11, 20);

flowLayOut.scrollDirection = UICollectionViewScrollDirectionHorizontal;

_collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 64, SCREENW, 40) collectionViewLayout:flowLayOut];

flowLayOut.minimumInteritemSpacing = 20;//最小值间隔gzz0920

flowLayOut.maximumInteritemSpacing = 20;//最大间隔

_collectionView.scrollEnabled = YES;

_collectionView.showsHorizontalScrollIndicator = NO;

_collectionView.showsVerticalScrollIndicator = NO;

_collectionView.dataSource = self;

_collectionView.delegate = self;

_collectionView.backgroundColor =  WHITECOLORS;//RGB(206, 248, 246);

[self.view addSubview:_collectionView];

[_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellColling"];

UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_collectionView.frame)-0.5, SCREEN_WIDTH, 0.5)];

line.backgroundColor = RGB(188, 188, 188);//[UIColor ];

lineview = line;

[self.view addSubview:line];

}

#pragma mark  标签请求

-(void)signRequest{

[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:@"%@polularScienceArticleTabList",Public_URL];

[manager POST: Srurl parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];

NSString *coder = [NSString stringWithFormat:@"%@",dic[@"code"]];

if ([coder isEqualToString:@"1"]) {

[tabMut addObjectsFromArray:dic[@"data"]];

}

[_collectionView reloadData];//gzz0804

if (tabMut.count>0) {

_collectionView.backgroundColor = WHITECOLORS;//RGB(206, 248, 246);

}else{

_collectionView.backgroundColor = WHITECOLORS;

}

} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

[MBProgressHUD hideHUDForView:self.view animated:YES];

_collectionView.backgroundColor = WHITECOLORS;

[self showHint:@"加载数据失败!"];

}];

}

#pragma mark  collectview datasource delegate  start

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{

return 1;

}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{

if (tabMut.count>0) {

return tabMut.count;

}else {

return 0;

}

}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

static NSString *identifier = @"cellColling";

UICollectionViewCell *cell = (UICollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

for (UIView *view in cell.contentView.subviews) {

[view removeFromSuperview];

}

cell.backgroundColor = [UIColor clearColor];

[cell.contentView addSubview:[self cellIndex:(int)indexPath.item]];

NSString  *names = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:indexPath.item] objectForKey:@"name"]];

for (int i=0; i<namesArr.count; i++) {

if ([namesArr containsObject:names]) {

cell.layer.borderColor = [[UIColor colorWithRed:60/255.0 green:199/255.0 blue:192/255.0 alpha:1] CGColor];

}

}

return cell;

}

-(UIView *)cellIndex:(NSInteger)index{

UIView  *viewdd = [[UIView alloc]initWithFrame:CGRectMake(0, 0.8, 100, 18)];

UILabel  *labell = [[UILabel alloc]init];

if (tabMut.count>0) {

viewdd.backgroundColor = [UIColor clearColor];

labell.frame = CGRectMake(0,0 , 100, 18);

labell.text = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:index] objectForKey:@"name"]];

labell.font = [UIFont systemFontOfSize:16];

[labell sizeToFit];

labell.tag = 4022+index;

labell.textColor = [UIColor grayColor];

labell.textAlignment = NSTextAlignmentCenter;

[viewdd addSubview:labell];

viewdd.frame = CGRectMake(viewdd.x, viewdd.y, labell.width, 18+0.8);

labell.centerY = viewdd.centerY;

labell.centerX = viewdd.centerX;

NSString  *names = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:index] objectForKey:@"name"]];

for (int i=0; i<namesArr.count; i++) {

if ([namesArr containsObject:names]) {

labell.textColor = [UIColor colorWithRed:60/255.0 green:199/255.0 blue:192/255.0 alpha:1];

}

}

}

return viewdd;

}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath

{

if(tabMut.count>0){

UILabel *labelW = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 18)];

labelW.text = [[tabMut objectAtIndex:indexPath.item] objectForKey:@"name"];

labelW.font = [UIFont systemFontOfSize:16];

[labelW sizeToFit];

return CGSizeMake(labelW.width, 18);

}else{

return CGSizeMake(0, 0);

}

}

///距边界缩放大小

//-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section

//{

//    return UIEdgeInsetsMake(13, 20, 9,20 );//分别为上、左、下、右6666gzz0920

//}

//UICollectionView被选中时调用的方法gzz0802

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

//    UICollectionViewCell  *cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];gzz0919w

NSString  *selectItem = [NSString stringWithFormat:@"select%zd",indexPath.item];

if (![selectM containsObject:selectItem]) {

[selectM removeAllObjects];

[signMut removeAllObjects];

[namesArr removeAllObjects];

[selectM addObject:selectItem];

//        cell.layer.cornerRadius = 12;

//        cell.layer.masksToBounds = YES;

//        cell.layer.borderWidth = 1;

//        cell.layer.borderColor = [[UIColor colorWithRed:60/255.0 green:199/255.0 blue:192/255.0 alpha:1] CGColor];

UILabel * lab = (UILabel *)[self.view viewWithTag:4022+indexPath.item];

lab.textColor = [UIColor colorWithRed:60/255.0 green:199/255.0 blue:192/255.0 alpha:1];

if (preIndexpath && preIndexpath != indexPath) {

//            UICollectionViewCell  *cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:preIndexpath];//gzz0919w

UILabel * lab = (UILabel *)[self.view viewWithTag:4022+preIndexpath.item];

lab.textColor = [UIColor grayColor];

}

NSString  *signS = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:indexPath.item] objectForKey:@"id"]];

[signMut addObject:signS];

//增加一个名字gzz0515

NSString  *names = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:indexPath.item] objectForKey:@"name"]];

[namesArr addObject:names];

signStr = [signMut componentsJoinedByString:@","];

number = 1;

_GardenPlotArray = [NSMutableArray array];

[self POScrienceRequest];

MCLog(@"选==%@,   现有=%@,传递数据 ===%@",signS,signMut,signStr);

}else{

NSString  *signS = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:indexPath.item] objectForKey:@"id"]];

[signMut removeObject:signS];

NSString  *names = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:indexPath.item] objectForKey:@"name"]];

[namesArr removeObject:names];

signStr = [signMut componentsJoinedByString:@","];

MCLog(@"去掉了==%@,还剩下=%@,传递 ===%@",signS,signMut,signStr);

number = 1;

_GardenPlotArray = [NSMutableArray array];

[self POScrienceRequest];

[selectM removeObject:selectItem];

UILabel * lab = (UILabel *)[self.view viewWithTag:4022+indexPath.item];

lab.textColor = [UIColor grayColor];

}

preIndexpath = indexPath;//gzz0802

}

#pragma mark  collect datasource delegate  end

#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;// BG_J_COLOR ;

_collectionView.backgroundColor = WHITECOLORS;//RGB(206, 248, 246);

lineview.hidden = NO;

}else{

imagershuju.hidden = NO;

tiwuxianLab.hidden = NO;

if (tabMut.count <=0) {

lineview.hidden = YES;

}

_collectionView.backgroundColor = WHITECOLORS;

}

[_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];

}];

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

return 80;

}

- (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];

}

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, 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];

UILabel *ttile=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(imagevview.frame)+5,6,SCREEN_WIDTH-25-102,16)];

ttile.text =[dic objectForKey:@"topic"];

ttile.backgroundColor=[UIColor clearColor];

ttile.font=[UIFont systemFontOfSize:16];

[cell.contentView addSubview:ttile];

UILabel* firstLabel = [[UILabel alloc] initWithFrame: CGRectMake(CGRectGetMaxX(imagevview.frame)+5, CGRectGetMaxY(ttile.frame)+5,ttile.width, 28)];

firstLabel.backgroundColor = [UIColor clearColor];

firstLabel.textColor = [UIColor grayColor];

firstLabel.numberOfLines=2;

firstLabel.font = [UIFont systemFontOfSize:14];

[cell.contentView addSubview:firstLabel];

NSString *summary=[NSString stringWithFormat:@"%@",[dic objectForKey:@"summary"]];

NSString *temp;

NSMutableArray *arr=[NSMutableArray array];

int sumIndex=0;

for(int i =0; i < [summary length]; i++)

{

temp = [summary substringWithRange:NSMakeRange(i, 1)];

NSString * regex = @"^[A-Za-z0-9]*$";

NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];

BOOL isMatch = [pred evaluateWithObject:temp];

if (isMatch) {

sumIndex++;

}

[arr addObject:temp];

}

NSArray *arrrr=[self kepuRemoveARRva:@" " arrayy:arr];

summary=[arrrr componentsJoinedByString:@""];

firstLabel.text=summary;

[firstLabel sizeToFit];

UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imagevview.frame)+5, 63, 40, 14)];

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)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 标签的点击请求

-(void)signCommitRequest{

[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:@"%@polularScienceArticleTabList",Public_URL];//

[manager POST: Srurl parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];

NSString *coder = [NSString stringWithFormat:@"%@",dic[@"code"]];

if ([coder isEqualToString:@"1"]) {

[tabMut addObjectsFromArray:dic[@"data"]];

}

[MBProgressHUD hideHUDForView:self.view animated:YES];

} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

[MBProgressHUD hideHUDForView:self.view animated:YES];

[self showHint:@"请求数据失败!"];

}];

}

#pragma  mark 去掉数组中的值。。。。

-(NSArray *)kepuRemoveARRva:(NSString *)str arrayy:(NSArray *)arr{

//需要去掉的元素数组

NSMutableArray *filteredArray = [[NSMutableArray alloc]initWithObjects:str, nil];

NSPredicate * filterPredicate = [NSPredicate predicateWithFormat:@"NOT (SELF IN %@)",filteredArray];

//过滤数组

NSArray * reslutFilteredArray = [arr filteredArrayUsingPredicate:filterPredicate];

return reslutFilteredArray;

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

}

@end

时间: 2024-10-12 04:07:03

科普园地的相关文章

《电信快报》2016.7目录

目录 行业动态 分享 融创 协同 生态 --2016中国互联网大会亮点频闪1 技术交流 LTE通信系统中的定位技术研究郎为民, 王大鹏, 吴 帆    3 智慧校园一卡通与教务系统对接设计 王永建, 张春献, 张   鑫, 曹西良  10 基于超融合的存储架构研究李志远, 杨文静, 温 钰  14 基于WiMAX与IP承载网的视频监控应用研究杨 刚  18 4G网络中反欺诈URL方案简析彭 鹏, 张 燕, 赵业祯  21 论文选粹 非授权频段无线局域网拥塞解决方案虞启亮  24 智慧城市一卡通系

170616

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000; min-height: 21.0px } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #c81b13 } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000 }

科普:一片晶圆可以切多少个芯片?

一片晶圆到底可以切割出多少的晶片数目?这个要根据die的大小和wafer的大小以及良率来决定的. 目前业界所谓的6寸,12寸还是18寸晶圆其实就是晶圆直径的简称,只不过这个寸是估算值.实际上的晶圆直径是分为150mm,300mm以及450mm这三种,而12寸约等于305mm,为了称呼方便所以称之为12寸晶圆. 国际上Fab厂通用的计算公式: 聪明的读者们一定有发现公式中:π*(晶圆直径/2)的平方 不就是圆面积的式子吗?再将公式化简的话就会变成: X 就是所谓的晶圆可切割晶片数(dpw:die

月攒亿级热度才上榜,科普、资讯内容成4月秒拍榜单黑马

依靠近20亿次播放量,魔力TV实现了在MCN榜上的蝉联:6亿播放的二更视频重回原创榜首:一手video竟然压过了央视新闻.人民日报.澎湃新闻等一众王牌媒体,成为风云榜上的状元--5月2日,秒拍发布2017年4月份系列榜单上,呈现出一个极其强烈的内容创业趋势-- 一个月没个亿级的热度,都不好意思在榜单上去排队. 文/张书乐 TMT行业观察者.游戏产业时评人,人民网.人民邮电报专栏作者 热度.画风.话锋--怎样的内容最有眼球 纵观风云榜.美食榜.时尚榜.影响力榜.原创榜和MCN榜6大榜单,有一个印象

《癌症&#183;真相:医生也在读》:癌症新药专家的癌症防治科普,重点是免疫疗法。四星推荐。

作者是美国诺华制药癌症新药开发部资深研究员,本书是作者对最新的癌症药物研发的科普.重点是免疫疗法和靶向治疗(估计免疫疗法是作者的研究方向).此外还有对癌症相关的传言的辟谣,和如何到美国去看病的指南. 行文风格通俗易懂,可读性比癌症科普名著<众病之王>要高一颗星.给4星是因为毕竟是个人的著作,权威性略差.期望能有权威的机构来写类似的书. 根据书中对一些时事的引用来判断,大部分内容应该是2015年写的. 以下是书中一些重要内容的摘抄: 1:我做癌症研究已经超过20年了.我可以非常诚恳地说,迄今为止

【游戏科普】使用心理学法则创建优秀的用户界面

原文:GameDev =================================================================== 实践证明,心理学的法则可以适用于游戏的用户界面的设计. 当你开始设计游戏的用户界面时,无论它是一个等级选择菜单,或是游戏内的地图,或是生命条,都很重要.完美的UI设计是无形的,也就是说,用户并不是真的在与UI的工作机制进行拼杀 - 用户界面仿佛消失一般,而玩家专注于游戏中的世界. 我最喜欢的类比就是开车的时候.当你第一次学习如何驾驶时,你需

《一口好牙》:三甲医院口腔科医生的科普。4星。

本书作者自称三甲医院口腔科医生,本书是他的口腔科的科普,主要内容是口腔科常见问题的医学解答.看完后我对作者的身份基本没有疑问.但是感觉作者不敢署真名,有点遗憾,降低了可信度.另外个人的科普的可信度要略差一些,因此我给4星. 以下是书中一些内容的摘抄,#号后面是kindle电子书中的页码: 1:我就一句话:在条件允许的情况下,建议所有智齿都拔掉.#93 2:作为口腔医生,我对牙膏的广告真是又爱又恨.爱的是牙膏作为常用的日用品之一得到了广泛推广,恨的是牙膏的广告宣传方式非常有问题,因为用任何牙膏都不

【科普】#001 大数据相关技术技术

由于不是大数据的开发人员,因此对大数据的知识,也就只是需要简单的理解,大数据有什么技术,都有什么用,这样就够了 大数据我们都知道hadoop,可是还会各种各样的技术进入我们的视野:Spark,Storm,impala,让我们都反映不过来.为了能够更好的架构大数据项目,这里整理一下,供技术人员,项目经理,架构师选择合适的技术,了解大数据各种技术之间的关系,选择合适的语言. 我们可以带着下面问题来阅读本文章: 1.hadoop都包含什么技术2.Cloudera公司与hadoop的关系是什么,都有什么

压缩感知(compressed sensing)科普两则

文章贴自:http://www.cvchina.info/2010/06/08/compressed-sensing-2/#more-1173 这是数学家陶哲轩在他自己的blog上写的一篇科普文章,讨论的是近年来在应用数学领域里最热门的话题之一:压缩感知(compressed sensing). 所谓压缩感知,最核心的概念在于试图从原理上降低对一个信号进行测量的成本.比如说,一个信号包含一千个数据,那么按照传统的信号处理理论,至少需要做一 千次测量才能完整的复原这个信号.这就相当于是说,需要有一