view 标签
//
// 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-0.5
#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;
}
@property (nonatomic,strong) UITableView *PopulaTableview;
@property (nonatomic,strong) NSMutableArray *GardenPlotArray;
@end
@implementation PopularizaOfScience
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
isRequest = NO;
[_PopulaTableview reloadData];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"科普园地";
self.view.backgroundColor=[UIColor whiteColor];
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;
_GardenPlotArray = [NSMutableArray array];
selectM = [NSMutableArray array];
number=1;
isRequest = NO;
signStr = @"";
tabMut = [NSMutableArray array];
signMut = [NSMutableArray array];
UIImageView *imageBim1 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"jianbian5"]];
imageBim1.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
imageBim = imageBim1;
[self.view addSubview:imageBim1];
[self signRequest];
[self Popuofview];
[self POScrienceRequest];
}
//下拉刷新
- (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++;
// [pudb.Newmuwarr removeAllObjects];
[pudb POScrienceRequest];
[pudb.PopulaTableview footerEndRefreshing];
}];
}
#pragma mark UI界面
- (void)Popuofview
{
_PopulaTableview = nil;
//gzz0422dai 标签
[self SignalUI];
//gzz0422
CGFloat colMheight = CGRectGetMaxY(_collectionView.frame); //100+64
if (tabMut.count <=0) {
colMheight = 0;
self.PopulaTableview = [[UITableView alloc]initWithFrame:CGRectMake(0,64, SCREEN_WIDTH, SCREEN_HEIGHT-64)];
}else{
self.PopulaTableview = [[UITableView alloc]initWithFrame:CGRectMake(0, colMheight, SCREEN_WIDTH, SCREEN_HEIGHT-colMheight)];
}
_PopulaTableview.showsVerticalScrollIndicator = NO;
_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(188, 188, 188);
tiwuxianLab.hidden = YES;
tiwuxianLab.font = SYSTEMFONT(TishiLabFont);
[self.view addSubview:tiwuxianLab];
[self haderwith];
[self Downrefresh];
}
-(void)SignalUI{
_collectionView = nil;
CustomFlowLayout *flowLayOut = [[CustomFlowLayout alloc]init];
// flowLayOut.sectionInset = UIEdgeInsetsMake(0.5, 0.5, 0.5, 0.5);//上左下右
flowLayOut.scrollDirection = UICollectionViewScrollDirectionVertical;//滚动方向
_collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 64, SCREENW, 0) collectionViewLayout:flowLayOut];
flowLayOut.minimumInteritemSpacing =1;
flowLayOut.maximumInteritemSpacing =6;
NSInteger lengthd = 0;
if (tabMut.count > 0) {
for (int i =0 ; i<tabMut.count; i++) {
NSString *str11 = [NSString stringWithFormat:@"%@",[tabMut objectAtIndex:i]];
lengthd += str11.length;
}
if (SCREEN_WIDTH == 320)
{
if (tabMut.count<=3 && tabMut.count>=1) {
_collectionView.height = 50;
}else if (tabMut.count <=6 && tabMut.count>3) {
if (lengthd < 14 && tabMut.count>=4) {
_collectionView.height = 50;
}else{
_collectionView.height = 100;
}
}else if(tabMut.count>6 &&tabMut.count<=8){
if (lengthd < 24) {
_collectionView.height = 100;
}else{
_collectionView.height = 150;
}
}else {
}
}
else if(SCREEN_WIDTH == 414)
{//6p
if (tabMut.count<=4 && tabMut.count>=1) {
_collectionView.height = 50;
}else if (tabMut.count <=8 && tabMut.count>4) {
if (lengthd < 14 && tabMut.count>=5) {
_collectionView.height = 50;
}else{
_collectionView.height = 100;
}
}else if(tabMut.count>8 &&tabMut.count<=12){
if (lengthd < 28) {
_collectionView.height = 100;
}else{
_collectionView.height = 150;
}
}else {
}
}
else
{//
MCLog(@"zheshi 6 375");
if (tabMut.count<=4 && tabMut.count>=1) {
_collectionView.height = 46;
}else if (tabMut.count <=8 && tabMut.count>4) {
if (lengthd < 17 && tabMut.count>=6) {
_collectionView.height = 46;
}else{
_collectionView.height = 92-9;
}
}else if(tabMut.count>8 &&tabMut.count<=12){
_collectionView.height = 46*3 -18;
// if (lengthd < 32) {
// _collectionView.height = 92;
//
// }else{
// _collectionView.height = 46*3 -9;
// }
}else {
}
}
}
_collectionView.scrollEnabled = NO;
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.backgroundColor = RGB(206, 248, 246);
[self.view addSubview:_collectionView];
[_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellColling"];
}
#pragma mark 标签请求
-(void)signRequest{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
AFHTTPRequestOperationManager *manger = [[AFHTTPRequestOperationManager alloc]init];
manger.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *Srurl = [NSString stringWithFormat:@"%@polularScienceArticleTabList",Public_URL];
[manger POST:Srurl parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:operation.responseData options:NSJSONReadingAllowFragments error:nil];
NSString *coder = [NSString stringWithFormat:@"%@",dic[@"code"]];
if ([coder isEqualToString:@"1"]) {
// [tabMut addObjectsFromArray:dic[@"data"]];
tabMut = [NSMutableArray arrayWithObjects:@"是但但三方",@"反倒但求",@"请但求",@"求的",@"是但三方",@"请求",@"是但是第三方",@"请求",@"请求但但",@"请求", nil];
// tabMut = [NSMutableArray arrayWithObjects:@"是但",@"反倒",@"请请求请求求",@"求的",@"反倒求",@"请求", nil];
// tabMut = [NSMutableArray arrayWithObjects:@"是但是第三方",@"反倒求",@"请求",@"求的",@"订的反倒求得", nil];
}
[self Popuofview];//gzz0429再次加载 防止异步比较慢
[MBProgressHUD hideHUDForView:self.view animated:YES];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
MCLog(@"---获取失败-error-");
}];
}
#pragma mark collectview datasource delegate start
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return tabMut.count;
}
- (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.layer.cornerRadius = 12;
cell.layer.masksToBounds = YES;
cell.layer.borderWidth = 1;
// cell.layer.borderColor = [[UIColor colorWithRed:248/255.0 green:189/255.0 blue:124/255.0 alpha:1] CGColor];//RGB(60, 199, 192)
// cell.layer.borderColor = [[UIColor colorWithRed:60/255.0 green:199/255.0 blue:192/255.0 alpha:1] CGColor];
cell.layer.borderColor = [[UIColor grayColor] CGColor];
[cell.contentView addSubview:[self cellIndex:(int)indexPath.item]];
return cell;
}
-(UIView *)cellIndex:(NSInteger)index{
// CGFloat www = (SCREEN_WIDTH-18-20)/4;
UIView *viewdd = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTHCOLLECTION, 28)];
UILabel *labell = [[UILabel alloc]init];
if (tabMut.count>0) {
viewdd.backgroundColor = [UIColor clearColor];
labell.frame = CGRectMake(0, 0 ,WIDTHCOLLECTION, 28);
// labell.text = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:index] objectForKey:@"name"]];
labell.text = [NSString stringWithFormat:@"%@",[tabMut objectAtIndex:index]];
labell.font = [UIFont systemFontOfSize:13];
labell.tag = 4022+index;
labell.textColor = [UIColor grayColor];
labell.textAlignment = NSTextAlignmentCenter;
[viewdd addSubview:labell];
}
viewdd.backgroundColor = [UIColor yellowColor];
return viewdd;
//
// UIView *viewdd = [[UIView alloc]initWithFrame:CGRectMake(2.5, 5, 100, 20)];
// UILabel *labell = [[UILabel alloc]init];
// if (tabMut.count>0) {
// viewdd.backgroundColor = [UIColor clearColor];
// labell.frame = CGRectMake(6,2 , 100, 20);
//// labell.text = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:index] objectForKey:@"name"]];
// labell.text = [NSString stringWithFormat:@"%@",[tabMut objectAtIndex:index] ];
// labell.font = [UIFont systemFontOfSize:13];
// [labell sizeToFit];
// labell.tag = 4022+index;
// labell.textColor = [UIColor grayColor];
// labell.textAlignment = NSTextAlignmentCenter;
// [viewdd addSubview:labell];
// viewdd.frame = CGRectMake(viewdd.x+2, viewdd.y, labell.width+14, 20);
// }
// return viewdd;
}
//每个cell的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
if(tabMut.count>0){
// CGFloat www = (SCREEN_WIDTH-18-10)/4;
return CGSizeMake(WIDTHCOLLECTION, 28);
}else{
return CGSizeMake(0, 0);
}
// if(tabMut.count>0){
// UILabel *labelW = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 16)];
//// labelW.text = [[tabMut objectAtIndex:indexPath.item] objectForKey:@"name"];
// labelW.text = [tabMut objectAtIndex:indexPath.item];
//
// labelW.font = [UIFont systemFontOfSize:13];
// [labelW sizeToFit];
//
// return CGSizeMake(labelW.width+22, 30);
// }else{
//
// return CGSizeMake(0, 0);
//
// }
}
////距边界缩放大小
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
// return UIEdgeInsetsMake(15, 15, 15, 15);//分别为上、左、下、右
// return UIEdgeInsetsMake(9, 12, 9, 0);//分别为上、左、下、右6666
return UIEdgeInsetsMake(9, 9, 9,0 );//分别为上、左、下、右6666
}
//UICollectionView被选中时调用的方法
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
NSString *selectItem = [NSString stringWithFormat:@"select%zd",indexPath.item];
if (![selectM containsObject:selectItem]) {
[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];
NSString *signS = [NSString stringWithFormat:@"%@",[[tabMut objectAtIndex:indexPath.item] objectForKey:@"id"]];
[signMut addObject:signS];
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];
signStr = [signMut componentsJoinedByString:@","];
MCLog(@"去掉了==%@,还剩下=%@,传递 ===%@",signS,signMut,signStr);
number = 1;
_GardenPlotArray = [NSMutableArray array];
[self POScrienceRequest];
[selectM removeObject:selectItem];
cell.layer.cornerRadius = 12;
cell.layer.masksToBounds = YES;
cell.layer.borderWidth = 1;
cell.layer.borderColor = [[UIColor grayColor] CGColor];
UILabel * lab = (UILabel *)[self.view viewWithTag:4022+indexPath.item];
lab.textColor = [UIColor grayColor];
}
}
//////每个section中不同的行之间的行间距
//- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
//{
// return 9;//6de 是18
//}
#pragma mark collect datasource delegate end
#pragma mark 内容请求
- (void) POScrienceRequest
{
//String type
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
AFHTTPRequestOperationManager *manger = [[AFHTTPRequestOperationManager alloc]init];
manger.responseSerializer = [AFHTTPResponseSerializer serializer];
// NSString *Srurl = [NSString stringWithFormat:@"%@polularScienceArticleList",Public_URL];
NSString *Srurl = [NSString stringWithFormat:@"%@polularScienceArticleListByTab",Public_URL];//polularScienceArticleTabList
NSMutableDictionary *dicm = [NSMutableDictionary dictionary];
dicm[@"page"]=[NSString stringWithFormat:@"%d",number];
dicm[@"type"] = signStr;
[manger POST:Srurl parameters:dicm success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:operation.responseData options:NSJSONReadingAllowFragments error:nil];
NSString *coder = [NSString stringWithFormat:@"%@",dic[@"code"]];
if ([coder isEqualToString:@"1"]) {
[_GardenPlotArray addObjectsFromArray:dic[@"data"]];
}
if (_GardenPlotArray.count>0) {
imagershuju.hidden = YES;
tiwuxianLab.hidden = YES;
_PopulaTableview.backgroundColor = BG_J_COLOR ;
}else{
imagershuju.hidden = NO;
tiwuxianLab.hidden = NO;
_collectionView.hidden = NO;
imageBim.hidden = NO;
// self.view.backgroundColor = [UIColor whiteColor];
// _PopulaTableview.backgroundColor = [UIColor whiteColor];
}
[_PopulaTableview reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
// MCLog(@"kepu---%@",dic);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
MCLog(@"---获取失败-error-");
if (_GardenPlotArray.count>0) {
imagershuju.hidden = YES;
tiwuxianLab.hidden = YES;
}else{
imagershuju.hidden = NO;
tiwuxianLab.hidden = NO;
_collectionView.hidden = NO;
imageBim.hidden = NO;
// self.view.backgroundColor = [UIColor whiteColor];
// _PopulaTableview.backgroundColor = [UIColor whiteColor];
}
[_PopulaTableview reloadData];
}];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 80;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _GardenPlotArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *strint = @"cell";
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) {
//gzz0122
// NSDictionary *dic = [self clearErrorData:_GardenPlotArray[indexPath.row]];
NSDictionary *dic = [DicRemove clearErrorDataZanwu:_GardenPlotArray[indexPath.row]];//gzz0406
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:@"moren"]];
[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 = nil;
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(SCREEN_WIDTH - 95, 63, 85, 14)];
timeLabel.backgroundColor = [UIColor clearColor];
timeLabel.textColor = [UIColor grayColor];
[cell.contentView addSubview:timeLabel];
NSString *timestr=[NSString stringWithFormat:@"%@", [dic objectForKey:@"submitDate"]];
timestr=[timestr substringToIndex:10];
timeLabel.font=SYSTEMFONT(12);
timeLabel.textAlignment=NSTextAlignmentRight;
timeLabel.text = timestr;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (_GardenPlotArray.count) {
polularScienceArticleDetails *pou = [[polularScienceArticleDetails alloc]init];
// NSDictionary *dicertion = [self clearErrorData:_GardenPlotArray[indexPath.row]];
NSDictionary *dicertion = [DicRemove clearErrorDataZanwu:_GardenPlotArray[indexPath.row]];//gzz0406
pou.PoluDiction = dicertion;
[self.navigationController pushViewController:pou animated:YES];
}
}
- (void)backClick
{
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark 标签的点击请求
-(void)signCommitRequest{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
AFHTTPRequestOperationManager *manger = [[AFHTTPRequestOperationManager alloc]init];
manger.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *Srurl = [NSString stringWithFormat:@"%@polularScienceArticleTabList",Public_URL];//
[manger POST:Srurl parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:operation.responseData 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:^(AFHTTPRequestOperation *operation, NSError *error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
MCLog(@"---获取失败-error-");
}];
}
#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];
}
-(void)textgzz{
// if (tabMut.count -1 == index) {
// MCLog(@"这是最后一个哦 %zd",tabMut.count);
//
// NSInteger lengthd = 0;
// if (tabMut.count > 0) {
// for (int i =0 ; i<tabMut.count; i++) {
// NSString *str11 = [NSString stringWithFormat:@"%@",[tabMut objectAtIndex:i]];
// MCLog(@" 第 %zd个的长度是%zd",i,str11.length);
// lengthd += str11.length;
//
// }
//
// }
// NSInteger compareIn = lengthd * 13;
// MCLog(@" comparIn ====%zd",compareIn);
// //4s
// if (compareIn <250) {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 50);
// }else if (compareIn > 500 && compareIn <750){
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 100);
// }else{
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 150);
// }
//
//
// }
// MCLog(@" zong 长度是%zd",lengthd);
// MCLog(@"tabMut.count = %zd",tabMut.count);
// if ((lengthd < 10 && tabMut.count <5) || ((lengthd>10&&lengthd<=12 )&& tabMut.count<3 )) {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 50);
//
// }else
// {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 100);
//
// }
}
-(void)before{
// if (tabMut.count -1 == index) {
// MCLog(@"这是最后一个哦 %zd",tabMut.count);
//
// NSInteger lengthd = 0;
// if (tabMut.count > 0) {
// for (int i =0 ; i<tabMut.count; i++) {
// NSString *str11 = [NSString stringWithFormat:@"%@",[tabMut objectAtIndex:i]];
// MCLog(@" 第 %zd个的长度是%zd",i,str11.length);
// lengthd += str11.length;
//
// }
//
// }
// NSInteger compareIn = lengthd * 13;
// MCLog(@" comparIn ====%zd",compareIn);
// //4s
// if (compareIn <250) {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 50);
// }else if (compareIn > 500 && compareIn <750){
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 100);
// }else{
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 150);
// }
// }
// if (SCREEN_WIDTH == 320) {
// // flowLayOut.minimumInteritemSpacing = 12;
//
// flowLayOut.maximumInteritemSpacing = 15;
//
//
//
// if (tabMut.count<=3 && tabMut.count>=1) {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 50);
//
// }else if (tabMut.count <=6 && tabMut.count>3) {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 100);
//
// }else if(tabMut.count>6 &&tabMut.count<=8){
// if (lengthd < 24) {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 100);
//
// }else{
//
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 150);
// }
//
// }else {
//
//
// }
//
//
// }else if(SCREEN_WIDTH == 375){//6
// if (tabMut.count<=4 && tabMut.count>=1) {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 50);
//
// }else
// if (tabMut.count <=8 && tabMut.count>4) {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 100);
// }else if(tabMut.count>8 &&tabMut.count<=12){
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 150);
//
// }else {
//
//
// }
// // flowLayOut.minimumInteritemSpacing = 18;
// flowLayOut.maximumInteritemSpacing = 15;
//
//
//
// }
//
// else {//6p
// if (tabMut.count<=4 && tabMut.count>=1) {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 50);
//
// }else
// if (tabMut.count <=8 && tabMut.count>4) {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 100);
// }else if(tabMut.count>8 &&tabMut.count<=12){
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 150);
//
// }else {
//
//
// }
// flowLayOut.maximumInteritemSpacing = 15;
//
//
////
// }
////
}
-(void)geshu{
// NSInteger compareIn = lengthd * 13;
// MCLog(@" 共有多少个字=%zd,comparIn ====%zd",lengthd,compareIn);
// //4s
// if (compareIn <245) {
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 50);
// }else if (compareIn > 245 && compareIn <490){//compareIn > 490 && compareIn <740
// if (lengthd >24) {
//
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 150);
// }else{
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 100);
// }
// }else{
// _collectionView.frame = CGRectMake(_collectionView.x, _collectionView.y, _collectionView.width, 150);
// }
}
@end
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步