ios图片放大
来源:互联网 发布:网络查水表是什么意思 编辑:程序博客网 时间:2024/05/16 11:39
//
// BedroomInspectionViewController.m
// ToiletinspectionReport
//
// Created by admin on 13-9-3.
// Copyright (c) 2013年 admin. All rights reserved.
//
#import "DetailViewController.h"
#import "DetailTableViewCell.h"
#import "AppDelegate.h"
#import "PicProcess.h"
#import "NSArray+ObjectAtIndexStrict.h"
#define BIG_IMG_WIDTH 300.0
#define BIG_IMG_HEIGHT 300.0
@interface DetailViewController ()
{
NSArray *arraySett;
NSArray *sectionTitles;
AppDelegate *appDelegate;
NSArray * imagesDuiCuo;
int headerSection[5];
UIView *background;
}
@end
@implementation DetailViewController
@synthesize entity;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(UIImage *)imageFormImage:(UIImage*)image inRect:(CGRect)rect
{
CGImageRef sourceImageRef = [image CGImage];
CGImageRef newImageRef = CGImageCreateWithImageInRect(sourceImageRef, rect);
UIImage *newImage = [UIImage imageWithCGImage:newImageRef];
return newImage;
}
- (TIREntity*)getEntityCur
{
appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
if (appDelegate.entityCurr == nil)
{
NSLog(@"error");
}
return appDelegate.entityCurr;
}
- (void)viewDidLoad
{
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
if ( [[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0 )
{
self.edgesForExtendedLayout = UIRectEdgeNone;
//self.extendedLayoutIncludesOpaqueBars = NO;
//self.modalPresentationCapturesStatusBarAppearance = NO;
}
#endif
[super viewDidLoad];
//0,不合格,1,合格,2,未检查
imagesDuiCuo = [NSArray arrayWithObjects:[UIImage imageNamed:@"error.png"],[UIImage imageNamed:@"correct.png"],[NSNull null], nil];
headerSection[0] = 60;
headerSection[1] = 80;
headerSection[2] = 100;
headerSection[3] = 80;
headerSection[4] = 120;
// Do any additional setup after loading the view.
[self createDetailData];
AppDelegate *appDelegates=[[UIApplication sharedApplication] delegate];
NSInteger navigationBarPadding=appDelegates.navigationBarPadding;
NSUserDefaults *myDefaults = [NSUserDefaults standardUserDefaults];
NSData* data = [myDefaults objectForKey:@"AppConfigToilet"];
AppConfig* appConfig = [NSKeyedUnarchiver unarchiveObjectWithData:data];
[self.labelSection setText:appConfig.sectionName];
UIButton *lButton = [UIButton buttonWithType:UIButtonTypeCustom];
lButton.frame = CGRectMake(0.0, 0.0, 37.0+navigationBarPadding, 44.0);
[lButton setImage:[UIImage imageNamed:@"fanhui.png"] forState:UIControlStateNormal];
[lButton addTarget:self action:@selector(actionBack) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithCustomView:lButton];
leftButton.style = UIBarButtonItemStylePlain;
self.navigationItem.leftBarButtonItem = leftButton;
}
- (void)actionBack
{
[self.navigationController popViewControllerAnimated:YES];
}
-(NSMutableArray *)createArray:(int)indexSett
{
NSArray *stepsStatus = [entity.stepsStatus objectAtIndex:indexSett];
NSArray *stepsComments = [entity.stepsCommentsList objectAtIndex:indexSett];
NSArray *stepsCommitTimesList = [entity.stepsCommitTimesList objectAtIndex:indexSett];
int stepTimes = [stepsStatus count];
NSMutableArray * arraySettChild = [NSMutableArray arrayWithCapacity:[stepsStatus count]];
NSMutableArray * imagenamesList= [entity.stepsImagenamesLists objectAtIndexStrict:indexSett];
for (int i=0;i<stepTimes;i++)
{
DetailTableViewCell *cell1 = [self createMyCell];
UIImage *img = [imagesDuiCuo objectAtIndexStrict:[[stepsStatus objectAtIndexStrict:i] intValue]];
[cell1.imageDuiCuo setImage:img];
NSString *comment = [stepsComments objectAtIndexStrict:i];
[cell1.labelDescription setText:comment];
//shijian
NSString *time = [stepsCommitTimesList objectAtIndexStrict:i];
[cell1.labelTime setText:time];
[cell1.labelCheckTimes setText:[NSString stringWithFormat:@"第%d次检查结果",(i+1)]];
cell1.imageViewArray = [NSArray arrayWithObjects:
cell1.imageView1,
cell1.imageView2,
cell1.imageView3,
cell1.imageView4,
nil];
if ([imagenamesList isKindOfClass:[NSArray class]])
{
if([imagenamesList count] > i)
{
NSArray * imagenames = [imagenamesList objectAtIndexStrict:i];
if ([imagenames count]>0)
{
for (int indexImage=0;indexImage<[imagenames count];indexImage++)
{
if ([imagenames objectAtIndexStrict:indexImage] != [NSNull null])
{
UIImage *image = [PicProcess readImage:[imagenames objectAtIndexStrict:indexImage]];
[[cell1.imageViewArray objectAtIndexStrict:indexImage] setImage:image];
//lv start
[[cell1.imageViewArray objectAtIndexStrict:indexImage] setUserInteractionEnabled:YES ];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
[[cell1.imageViewArray objectAtIndexStrict:indexImage] addGestureRecognizer:singleTap];
//lv
}
}
}
}
}
[arraySettChild addObject:cell1];
}
return arraySettChild;
}
//点击事件 不修改原来的view
- (void)handleSingleTap:(UIGestureRecognizer *)gestureRecognizer {
UIView *temview=[gestureRecognizer view];
UIImageView * imagePicView = (UIImageView*)temview;
//创建灰色透明背景,使其背后内容不可操作
float screenHeight = [UIScreen mainScreen].bounds.size.height;
float screenWidth = [UIScreen mainScreen].bounds.size.width;
UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
background = bgView;
[bgView setBackgroundColor:[UIColor colorWithRed:0.3
green:0.3
blue:0.3
alpha:0.7]];
[self.view addSubview:bgView];
//创建边框视图
UIView *borderView = [[UIView alloc] initWithFrame:CGRectMake(0, 10,BIG_IMG_WIDTH+16, BIG_IMG_HEIGHT+16)];
//将图层的边框设置为圆脚
borderView.layer.cornerRadius = 8;
borderView.layer.masksToBounds = YES;
//给图层添加一个有色边框
borderView.layer.borderWidth = 8;
borderView.layer.borderColor = [[UIColor colorWithRed:0.9
green:0.9
blue:0.9
alpha:0.7]CGColor];
[bgView addSubview:borderView];
//创建关闭按钮
UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[closeBtn setImage:[UIImage imageNamed:@"guanb@2x.png"] forState:UIControlStateNormal];
[closeBtn addTarget:self action:@selector(closePicView) forControlEvents:UIControlEventTouchUpInside];
NSLog(@"borderview is %@",borderView);
[closeBtn setFrame:CGRectMake(borderView.frame.origin.x+borderView.frame.size.width-20, borderView.frame.origin.y-6, 26, 27)];
[bgView addSubview:closeBtn];
//创建显示图像视图
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, BIG_IMG_WIDTH, BIG_IMG_HEIGHT)];
[imgView setImage:imagePicView.image];
[borderView addSubview:imgView];
}
//图片预览关闭
-(void)closePicView
{
[background removeFromSuperview];
}
-(void)createDetailData
{
entity = [self getEntityCur];
NSString *title1 = @"1.沉池结构闭水检验";
NSString *title2 = @"2.二次侧排水及第一道防水涂料检查";
NSString *title3 = @"3.回填检查(旁边及隐蔽验收)";
NSString *title4 = @"4.二次防水检查";
NSString *title5 = @"5.试面及门框安装完成后的试水检验";
sectionTitles = [[NSArray alloc] initWithObjects:title1,title2,title3,title4,title5, nil];
NSMutableArray *arraySett01 = [self createArray:0];
NSMutableArray *arraySett02 = [self createArray:1];
NSMutableArray *arraySett03 = [self createArray:2];
NSMutableArray *arraySett04 = [self createArray:3];
NSMutableArray *arraySett05 = [self createArray:4];
arraySett = [[NSArray alloc] initWithObjects:arraySett01,arraySett02,arraySett03,arraySett04,arraySett05, nil];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 135;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [arraySett count];
}
-(DetailTableViewCell *)createMyCell
{
NSString *identifierDetailCell = @"detailCell";
DetailTableViewCell *cell = [self.myTableView dequeueReusableCellWithIdentifier:identifierDetailCell];
if (cell == nil)
{
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"DetailTableViewCell" owner:self options:nil];
cell = [array objectAtIndex:0];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailTableViewCell *cell = [[arraySett objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
return cell;
}
/*
-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
//return [sectionTitles objectAtIndex:section];
}*/
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSArray *tempArray = [arraySett objectAtIndex:section];
return [tempArray count];
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIImageView *view = [[UIImageView alloc] init];
UIImage *imageBg = [self imageFormImage:[UIImage imageNamed:@"appbg.png"] inRect:CGRectMake(0, 0, 320, headerSection[section])];
[view setImage:imageBg];
UILabel * label01 = [[UILabel alloc] initWithFrame:CGRectMake(21, 2, 280, 20)];
[label01 setText:[sectionTitles objectAtIndex:section]];
label01.font = [UIFont systemFontOfSize:16];
label01.backgroundColor = [UIColor clearColor];
[view addSubview:label01];
UILabel * label02 = [[UILabel alloc] initWithFrame:CGRectMake(41, 22, 280, headerSection[section]-30)];
[label02 setText:[appDelegate.stepContents objectAtIndex:section]];
label02.font = [UIFont systemFontOfSize:12];
label02.backgroundColor = [UIColor clearColor];
[label02 setNumberOfLines:0];
UIImageView *lvxianView = [[UIImageView alloc] initWithFrame:CGRectMake(11, 0, 2, headerSection[section])];
UIImage *lvxian = [self imageFormImage:[UIImage imageNamed:@"lvxian.png"] inRect:CGRectMake(0, 0, 2, headerSection[section])];
[lvxianView setImage:lvxian];
[view addSubview:lvxianView];
UIImageView *duiCuoView = [[UIImageView alloc] initWithFrame:CGRectMake(290, 4, 15, 15)];
NSArray *stepStatus = [entity.stepsStatus objectAtIndex:section];
if ([stepStatus count]>0)
{
UIImage *img = [imagesDuiCuo objectAtIndex:[[stepStatus objectAtIndex:([stepStatus count] - 1)] intValue]];
[duiCuoView setImage:img];
[view addSubview:duiCuoView];
}
[view addSubview:label02];
return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return headerSection[section];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
- ios下拉放大图片
- ios图片放大
- ios图片放大缩小
- ios下拉图片放大
- iOS 点击图片放大Demo
- iOS图片点击点击放大
- iOS tableView下拉图片放大
- ios下拉放大图片效果
- iOS 图片点击放大封装
- iOS 点击图片放大效果
- iOS 图片放大缩小动画
- iOS 点击图片放大效果
- iOS 下拉 图片放大 swift
- iOS 图片捏合放大缩小 点击放大缩小
- ios 根据手势放大或缩小图片
- ios 根据手势放大或缩小图片
- ios 根据手势放大或缩小图片
- ios 根据手势放大或缩小图片
- 谭叹囊帜腾芯尘商赐胰断毯患帜伪
- 执桶亚凑桶撼坟钥账磷傧圃空滦赌
- Eclipse 常用插件安装
- 5、Android中使用AsyncTask异步更新UI界面
- 免费电子书列表
- ios图片放大
- Android( linux )下常用拷贝命令
- Jsp+servlet 验证码案例
- ASP.NET MVC URL重写与优化(进阶篇)-继承RouteBase玩转URL
- Windows Phone 8 开发快速入门(八)
- linux安装Oracle11gR2
- [Linux]Linux的运行库
- 三菱召回部分进口欧蓝德EX汽车 中国大陆地区涉5..
- Cookie学习笔记一:基本概念