#pragma mark - /// //图片部分
for (int i = 0; i < [_imageArray count]; i++) {
UIImageView * imageV = (UIImageView *)[_imageArray objectAtIndex:i];
if (imageV.superview) {
[imageV removeFromSuperview];
}
}
[_imageArray removeAllObjects];
//自定义图片高度
CGFloat showImageH ;
for (int i = 0; i < [ymData.showImageArray count]; i++) {
//假定图片的高就是80了ShowImage_H----kDistance 20 //说说和图片的间隔---#define TableHeader 50
//自己改的
showImageH = 80;//(IPHONE_WIDTH - 50)/3;
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(20 + 5*(i%3) + showImageH*(i%3), TableHeader - 3 + 5 * ((i/3) + 1) + (i/3) * showImageH + hhhh + kDistance + (ymData.islessLimit?0:30), showImageH, showImageH)];
imageView.contentMode = UIViewContentModeScaleToFill;
// UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(((screenWidth - 240)/4)*(i%3 + 1) + 80*(i%3), TableHeader + 10 * ((i/3) + 1) + (i/3) * ShowImage_H + hhhh + kDistance + (ymData.islessLimit?0:30), 80, ShowImage_H)];
imageView.userInteractionEnabled = YES;
YMTapGestureRecongnizer *tap = [[YMTapGestureRecongnizer alloc] initWithTarget:self action:@selector(tapImageView:)];
[imageView addGestureRecognizer:tap];
tap.appendArray = ymData.showImageArray;
imageView.backgroundColor = [UIColor clearColor];
imageView.tag = kImageTag + i;
// image.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[ymData.showImageArray objectAtIndex:i]]];
NSString *imgStr = [[ymData.showImageArray objectAtIndex:i] stringByReplacingOccurrencesOfString:@"." withString:@"."];
NSString *imgStr_S = [imgStr stringByReplacingOccurrencesOfString:@"." withString:@"_s."];
NSString *urlStr_S = [NSString stringWithFormat:KimgUrl@"dynamic/%@",imgStr_S];
NSLog(@"-------朋友圈- 缩略图 -images-----:urlStr------%@",urlStr_S);
// UIImage *placeholder = [UIImage imageNamed:@"hstp"];
// NSString *urlStr = [NSString stringWithFormat:KimgUrl@"dynamic/%@",imgStr];
// [image setImageURLStr:urlStr placeholder:placeholder];
__block UIActivityIndicatorView *activityIndicator;
[imageView sd_setImageWithURL:[NSURL URLWithString:urlStr_S] placeholderImage:[UIImage imageNamed:@"mrbg1"] options:SDWebImageProgressiveDownload progress:^(NSInteger receivedSize, NSInteger expectedSize) {
if (!activityIndicator)
{
activityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.center = imageView.center;
//把更新UI放到主线程
dispatch_async(dispatch_get_main_queue(), ^{
[imageView addSubview:activityIndicator];
});
[activityIndicator startAnimating];
}
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
float a = image.size.width;
float b = image.size.height;
NSLog(@"----width--%f----height--%f-------",a,b);
if ([ymData.showImageArray count] == 1) {
// [imageView sizeToFit];
imageView.frame = CGRectMake(20 + 5*(i%3) + showImageH*(i%3), TableHeader - 3 + 5 * ((i/3) + 1) + (i/3) * showImageH + hhhh + kDistance + (ymData.islessLimit?0:30), a/4, b/4);
// showImageH = imageView.frame.size.height;
_ShowImage_HH = 150;//600/4;
}else{
_ShowImage_HH = 80;
}
//改变图片的显示方式-----让它不压缩,部分显示
[activityIndicator stopAnimating];
}];
//
// NSLog(@"------image--- cell --- 尺寸-----%@",NSStringFromCGSize(image.image.size));
//
//
//
// NSURL *url_S = [NSURL URLWithString:urlStr_S];
// NSData *resultData_S = [NSData dataWithContentsOfURL:url_S];
// NSLog(@"------cell-图片大小_S--------%lu",(unsigned long)[resultData_S length]);
// UIImage *img_S = [UIImage imageWithData:resultData_S];
// NSLog(@"------cell--图片尺寸_S-------%@",NSStringFromCGSize(img_S.size));
//
[self.contentView addSubview:imageView];
[_imageArray addObject:imageView];
}