cellForRowAtIndexPath 设置图片
#import "UIImageView+MJWebCache.h"
#import "MJPhotoBrowser.h"
#import "MJPhoto.h"
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"HZWuYePhotoListCell";
HZWuYePhotoListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[HZWuYePhotoListCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier: CellIdentifier];
}
cell.clipsToBounds = YES;
//选中cell背景色无色
cell.selectionStyle = UITableViewCellSelectionStyleNone;
HZWuyephoto *Wuyephoto = [self.dataArray objectAtIndex:indexPath.row];
NSArray *statusestemp = [HZWuyePhotoList objectArrayWithKeyValuesArray:Wuyephoto.list];
cell.PhotoTime.numberOfLines=0;
cell.PhotoTime.text=[Utils getFormateDateAndTime:Wuyephoto.create_date timeStr:Wuyephoto.create_time];
[cell.PhptoComment setFont:[UIFont systemFontOfSize:13]];
cell.PhptoComment.text= Wuyephoto.task_description;
cell.PhptoComment.numberOfLines=0;
//设置图片
if (Wuyephoto.list != nil && Wuyephoto.list.count > 0) {
cell.PhotoFatherView.frame = CGRectMake(100, 10, 100, 100);
// cell.PhotoBgimg.hidden = NO;
NSArray *imgArray = @[cell.PhotoImg1,cell.PhotoImg2,cell.PhotoImg3,cell.PhotoImg4];
cell.PhotoImg4.hidden = YES;
cell.PhotoImg3.hidden = YES;
cell.PhotoImg2.hidden = YES;
cell.PhotoImg1.hidden = YES;
cell.PhotoCount.hidden = YES;
cell.PhotosView.hidden = NO;
cell.PhotoImg1.image = nil;
cell.PhotoImg2.image = nil;
cell.PhotoImg3.image = nil;
cell.PhotoImg4.image = nil;
cell.PhotoTime.frame=CGRectMake(220,10, 100, 15);
cell.PhotoMouth.frame=CGRectMake(-160,15, 30, 80);
cell.PhptoComment.frame=CGRectMake(120, 32, 190, 68);
if (Wuyephoto.list.count==1) {
cell.PhotoImg1.frame= CGRectMake(0, 0,100, 100);
cell.PhotosView.frame= CGRectMake(10, 15, 100, 100);
}else if (Wuyephoto.list.count==2){
cell.PhotoImg1.frame= CGRectMake(0, 0, 49, 100);
cell.PhotoImg2.frame= CGRectMake(51, 0, 49, 100);
cell.PhotosView.frame= CGRectMake(10, 15, 100, 100);
}else if (Wuyephoto.list.count==3){
cell.PhotosView.frame= CGRectMake(10, 15, 100, 100);
cell.PhotoImg1.frame= CGRectMake(0, 0, 49, 49);
cell.PhotoImg2.frame= CGRectMake(51, 0, 49, 49);
cell.PhotoImg3.frame= CGRectMake(0, 51, 100, 49);
}else if (Wuyephoto.list.count==4){
cell.PhotosView.frame= CGRectMake(10, 15, 100, 100);
cell.PhotoImg1.frame= CGRectMake(0, 0, 49, 49);
cell.PhotoImg2.frame= CGRectMake(51, 0, 49, 49);
cell.PhotoImg3.frame= CGRectMake(0, 51, 49, 49);
cell.PhotoImg4.frame= CGRectMake(51, 51, 49, 49);
}else if (Wuyephoto.list.count>4){
cell.PhotosView.frame= CGRectMake(10, 15,100, 100);
cell.PhotoImg1.frame= CGRectMake(0, 0, 49, 49);
cell.PhotoImg2.frame= CGRectMake(51, 0, 49, 49);
cell.PhotoImg3.frame= CGRectMake(0, 51, 49, 49);
cell.PhotoImg4.frame= CGRectMake(51, 51, 49, 49);
cell.PhotoCount.hidden = YES;
cell.PhotoCount.frame= CGRectMake(190, 85, 100, 15);
[cell.PhotoCount setFont:[UIFont systemFontOfSize:11]];
// cell.PhotoCount.text=(NSString *)Wuyephoto.list.count;
}
for (int i = 0; i < (Wuyephoto.list.count>4?4:Wuyephoto.list.count); ++i) {
HZWuyephoto *testP=statusestemp[i];
// for (int i=0; i<self.statuses2.count; i++) {
// HZWuyephoto *testP=self.statuses2[i];
//
// DLog(@"====%@=====end",testP.file_path);
//
// }
NSString *url = testP.file_path;
UIImageView *tempImgView = [imgArray objectAtIndex:i];
tempImgView.hidden = NO;
[tempImgView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",AppInfoService,url]] placeholderImage:[UIImage imageNamed:@"acct_my_header_icon.jpg"]];
tempImgView.userInteractionEnabled = YES;
tempImgView.contentMode = UIViewContentModeScaleAspectFill;
tempImgView.clipsToBounds = YES;
NSString *cellindex = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
NSString *imageInt = [NSString stringWithFormat:@"%d",i];
NSString *ImgViewstringInt = [NSString stringWithFormat:@"%@%@",cellindex,imageInt];
int indexint = [ImgViewstringInt intValue];
tempImgView.tag=indexint;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showImage:)];
[tempImgView addGestureRecognizer:tap];
}
// [cell.contentView addSubview:cell.PhotoFatherView];
// [cell.PhotoFatherView addSubview:cell.PhotoImg1];
// [cell.PhotoFatherView addSubview:cell.PhotoImg2];
// [cell.PhotoFatherView addSubview:cell.PhotoImg3];
// [cell.PhotoFatherView addSubview:cell.PhotoImg4];
}else{
cell.PhotoTime.frame=CGRectMake(220,10, 100, 15);
cell.PhotoMouth.frame=CGRectMake(-160,15, 30, 80);
cell.PhptoComment.frame=CGRectMake(120, 32, 190, 68);
cell.PhotoImg1.frame= CGRectMake(0, 0,100, 100);
cell.PhotosView.frame= CGRectMake(10, 15, 100, 100);
cell.PhotoCount.hidden = YES;
cell.PhotoImg1.image=[UIImage imageNamed:@"acct_my_header_icon.jpg"];
}
// 3.设置字体
// self.text_think.font = [UIFont systemFontOfSize:15];
//设置地址图标
// cell.PhotoAddressImg = Wuyephoto.task_description;
//设置地址名称(暂时没有)
//投诉的类别和分类等对应参数值如下
/*
static {
TASK_TYPE.put("1", "投诉");
TASK_TYPE.put("2", "报修");
TASK_TYPE.put("3", "表扬");
TASK_TYPE.put("4", "意见建议");
}
*/
/*
static {
COMPLAIN_CSP_TYPE.put("1", "保绿");
COMPLAIN_CSP_TYPE.put("2", "保安");
COMPLAIN_CSP_TYPE.put("3", "保洁");
COMPLAIN_CSP_TYPE.put("4", "保修");
COMPLAIN_CSP_TYPE.put("5", "服务态度");
}
*/
//设置地址
cell.PhotoAddressLabel.font = [UIFont systemFontOfSize:10];
cell.PhotoAddressLabel.frame=CGRectMake(120, 100, 110, 20);
//设置评论
cell.PhotoAttitudeLab.frame=CGRectMake(120, 10, 40, 15);
cell.PhotoAttitudeLab2.frame=CGRectMake(160, 10, 50, 15);
cell.PhotoAttitudeLab.font = [UIFont systemFontOfSize:12];
cell.PhotoAttitudeLab2.font = [UIFont systemFontOfSize:12];
// cell.PhotoAttitudeLab.hidden=YES;
// cell.PhotoAttitudeLab2.hidden=YES;
// 设置圆角(边长的一半)
cell.PhotoCommentBtn.layer.cornerRadius=5;
// 从父视图中剪切超出的部分
cell.PhotoCommentBtn.clipsToBounds=YES;
if ([Wuyephoto.task_type isEqualToString:@"1"]) {
[cell.PhotoCommentBtn setTitle:@"反应问题" forState:UIControlStateNormal];
cell.PhotoAttitudeLab.text=@"";
cell.PhotoCommentBtn.frame=CGRectMake(120, 10, 70, 20);
}else if ([Wuyephoto.task_type isEqualToString:@"3"]) {
[cell.PhotoCommentBtn setTitle:@"表扬" forState:UIControlStateNormal];
cell.PhotoAttitudeLab.text=@"";
cell.PhotoCommentBtn.frame=CGRectMake(120, 10, 40, 20);
}if ([Wuyephoto.task_type isEqualToString:@"4"]) {
[cell.PhotoCommentBtn setTitle:@"意见建议" forState:UIControlStateNormal];
cell.PhotoCommentBtn.frame=CGRectMake(120, 10, 70, 20);
cell.PhotoAttitudeLab.text=@"";
}
if ([Wuyephoto.task_type isEqualToString:@"1"]) {
if ([Wuyephoto.complaint_content isEqualToString:@"1"]) {
cell.PhotoAttitudeLab2.text=@"";
}else if ([Wuyephoto.complaint_content isEqualToString:@"2"]) {
cell.PhotoAttitudeLab2.text=@"";
}else if ([Wuyephoto.complaint_content isEqualToString:@"3"]) {
cell.PhotoAttitudeLab2.text=@"";
}else if ([Wuyephoto.complaint_content isEqualToString:@"4"]) {
cell.PhotoAttitudeLab2.text=@"";
}else if ([Wuyephoto.complaint_content isEqualToString:@"5"]) {
cell.PhotoAttitudeLab2.text=@"";
}
}else{
cell.PhotoAttitudeLab2.text=@"";
}
cell.PhotoAddressLabel.text=[NSString stringWithFormat:@"%@%@%@",Wuyephoto.task_road,Wuyephoto.task_unit,Wuyephoto.task_unit_no];
cell.PhotoAddressLabel.hidden=YES;
return cell;
}
#pragma mark- 判断文本的宽高
-(CGFloat)getHeightSize:(NSString *)str allowSize:(CGFloat)width font:(UIFont *)font{
CGSize titleSize = [str sizeWithFont:font constrainedToSize:CGSizeMake(width, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];
return titleSize.height;
}
#pragma mark - UIViewControllerTransitioningDelegate methods
- (void)showImage:(UIGestureRecognizer *)ges {
NSString *indextag = [NSString stringWithFormat:@"%ld",(long)ges.view.tag];
NSString *strDay=[indextag substringWithRange:NSMakeRange(0, indextag.length-1)];
int intString = [strDay intValue];
NSString *strDay2=[indextag substringWithRange:NSMakeRange(indextag.length-1, 1)];
int imageint = [strDay2 intValue];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:intString inSection:0];
HZWuYePhotoListCell *cell = (HZWuYePhotoListCell *)[self.tableView cellForRowAtIndexPath:indexPath];
HZWuyephoto *theme = [self.dataArray objectAtIndex:indexPath.row];
self.statuses2 = [HZWuyePhotoList objectArrayWithKeyValuesArray:theme.list];
int count = (int)theme.list.count;
// 1.封装图片数据
NSMutableArray *photos = [NSMutableArray arrayWithCapacity:count];
for (int i = 0; i<(count>4?4:count); i++) {
HZWuyephoto *testP=self.statuses2[i];
// // 替换为中等尺寸图片
NSString *url =testP.file_path;
MJPhoto *photo = [[MJPhoto alloc] init];
photo.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",AppInfoService,url]]; // 图片路径
photo.srcImageView = cell.PhotosView.subviews[i]; // 来源于哪个UIImageView
[photos addObject:photo];
}
// 2.显示相册
MJPhotoBrowser *browser = [[MJPhotoBrowser alloc] init];
browser.currentPhotoIndex = imageint; // 弹出相册时显示的第一张图片是?
browser.photos = photos; // 设置所有的图片
[browser show];
// self.sImgView = (UIImageView *)[ges view];
// self.sImgView.backgroundColor=[UIColor blackColor];
//
// // NSLog(@"%f",self.sImgView.frame.size.width);
// TGRImageViewController *viewController = [[TGRImageViewController alloc] initWithImage:self.sImgView.image];
// viewController.transitioningDelegate = self;
//
// [ApplicationDelegate.tabBarController presentViewController:viewController animated:YES completion:nil];
}
cellForRowAtIndexPath 设置图片的更多相关文章
- Android设置图片内存溢出(OOM)问题——Android开发进阶之路6
ImageView设置图片必备常识技术: Android设备会给每个应用分配16M的内存空间,如果你设置的图片的比较大且同一个页面有多个时,经常会报OOM错误导致程序奔溃.所以在这种情况下我们必须要对 ...
- (转) JAVA中如何设置图片(图标)自适应Jlable等组件的大小
一.问题: 一个程序,组件上设置某个图片作为图标,因为的label(应该说是组件)已经设定了固定大小, 所以再打开一些大图片时,超过组件大小的部分没显示出来,而小图片又没填充完整个组件 二.解决这个问 ...
- Android drawableleft drawableTop 设置图片的大小
例子: Drawable drawable=getResources().getDrawable(R.drawable.xx); //获取图片 drawable.setBounds(left, top ...
- ios UIButton设置单选效果,以及同时设置图片和标题
一,设置单选效果 - (void)selectedBtnPress:(UIButton*)sender { //首先把原来按钮的选中效果消除 for (int i=0;i<num;i++) {/ ...
- 给tabBar设置图片和字体颜色的几种方法
现在很多应用都使用到了tabBar,我们往往在给tabBar设置图片和字体的时候,当选中状态下,往往字体的颜色和图片的颜色不匹配,有时候就显得无从下手,我也常常忘了,所有写这个博客的目的,相当于给自己 ...
- 在word里插入图片,并设置图片的格式
由于公司业务需要,需要在生成的word里插入图片(公司印章),仔细想了下,还是在word模板里添加一个书签,然后再该书签的位置插入图片,并设置图片的格式方便些: 代码如下: using System; ...
- CSS设置图片垂直居中的方法
如果是应用了表格,那么设置单元格为align="center"就可以使其中的一切内容居中.如果没有应用表格要想设置图片居中就有点困难了.困难来自不按"常规出牌" ...
- 将“Cocos2dx-截屏并设置图片尺寸 ”中cocos2d-x代码转换为2.2的代码
Cocos2dx-截屏并设置图片尺寸: http://www.cocos2dev.com/?p=522 2.2 代码如下: void HelloWorld::screenShoot() { CCSiz ...
- Android:ScaleType设置图片
设置例子:ImageViewId.setScaleType(ScaleType.CENTER); ScaleType:设置图片显示方式 效果预览:
随机推荐
- 二叉树的递归插入【Java实现】
C++中由于有指针的存在,可以让二叉树节点指针的指针作为插入函数的实参,在函数体内通过*操作实现对真实节点指针.节点左孩子指针.节点右孩子指针的改变,这样很容易使用递归将大树问题转化到小树问题.但在J ...
- linux网站发布操作流程
Linux 添加用户命令: useradd bm -g webTemp http://www.runoob.com/linux/linux-vim.html Linux关于网站发布操作流程 虚拟机地下 ...
- 【CS Round #43 C】Rectangle Partition
[链接]点击打开链接 [题意] 有一辆火车,它的长度为L,然后假设这辆车现在随机可能地出现在0..D之间,然后假设它已经耗光了油. 问你它需要走的期望距离是多少. 这里要走的距离指的是车里最近的加油站 ...
- Vijos 1164 曹冲养猪(中国剩余定理)
P1164曹冲养猪 Accepted 标签:三国争霸[显示标签] 描写叙述 自从曹冲搞定了大象以后,曹操就開始捉摸让儿子干些事业,于是派他到中原养猪场养猪,但是曹冲满不高兴.于是在工作中马马虎虎,有一 ...
- Android实践 -- Android蓝牙设置连接
使用Android Bluetooth APIs将设备通过蓝牙连接并通信,设置蓝牙,查找蓝牙设备,配对蓝牙设备 连接并传输数据,以下是Android系统提供的蓝牙相关的类和接口 BluetoothAd ...
- DIV+CSS学习笔记
第十五章 定位 static静态定位(不对它的位置进行改变,在哪里就在那里) 默认值.没有定位,元素出现在正常的流中(忽略 top, bottom, left, right 或者 z-index 声明 ...
- jmeter--响应断言
背景 在测试过程中,我们需要对某个请求的结果进行判定. 比如我们搜索“你好”,请求发送成功,返回响应码也是200,但是并不能说明返回的响应就是对的,我们可能还需要判定响应结果包含“你好”.这个时候,我 ...
- amazeui页面分析5
amazeui页面分析5 一.总结 1.把原模板当成样例集合就好 2.都是一块一块的,删改等操作都方便 3.list方面的操作很多都是ui配合li 4.其实容器本质还是div,所以真的算简单了 5.样 ...
- 百度ueditor vue项目应用 -- 图片上传源码修改
本文目的有两个,一.废掉单图上传,二.改造多图上传 大家都知道百度ueditor不是针对vue项目开发的,官方文档提供的源码包里有需要后端配置的接口,but到vue项目就不太好办了,网上有些文章也介绍 ...
- AE 向已存在的要素类中添加字段
风过无痕 原文向已存在的要素类中添加字段 以前,在用AE写程序的时候,为了方便,一般都是直接新建一个MapControl窗体应用程序.这次需要解决的问题用不到窗口,就突发奇想,直接新建了一个Conso ...