// // InfoByImageViewController.m // Ifish // // Created by 祝发冬 on 2020/6/20. // Copyright © 2020 lianlian. All rights reserved. // #import "InfoByImageViewController.h" @interface InfoByImageViewController () @end @implementation InfoByImageViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.scrollView=[[UIScrollView alloc]initWithFrame:CGRectZero]; //self.scrollView.clipsToBounds=YES; self.imageView=[[UIImageView alloc]initWithFrame:CGRectZero]; // self.imageView.contentMode=UIViewContentModeCenter; [self.scrollView addSubview:self.imageView]; //self.scrollView.scrollEnabled=NO; [self.view addSubview:self.scrollView]; self.imageView.userInteractionEnabled=YES; [ self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.bottom.mas_equalTo(0); make.right.mas_equalTo(0); }]; CGFloat imageHeight=kScreenHeight-TOP_HEIGHT; CGFloat imageWidth=kScreenWidth; CGFloat ratio=imageWidth/imageHeight; if (self.image) { ratio=self.image.size.width/self.image.size.height; } imageHeight=imageWidth/ratio; self.scrollView.contentSize=CGSizeMake(imageWidth, imageHeight); [ self.imageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.scrollView); make.top.mas_equalTo(self.scrollView); make.height.mas_equalTo(imageHeight); make.width.mas_equalTo(imageWidth); // make.right.mas_equalTo(self.view); }]; if (self.image) { self.imageView.image=self.image; } if (self.title) { self.titleString=self.title; } if ([self.type isEqualToString:@"service"]) { UIButton*xuanduo=[UIButton buttonWithType:UIButtonTypeSystem]; [self.imageView addSubview:xuanduo]; [xuanduo mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.height.mas_equalTo(imageHeight/12); make.right.mas_equalTo(0); }]; xuanduo.tag=1; xuanduo.backgroundColor=[UIColor clearColor]; [xuanduo addTarget:self action:@selector(service:) forControlEvents:UIControlEventTouchUpInside]; UIButton*reuxin=[UIButton buttonWithType:UIButtonTypeSystem]; [self.imageView addSubview:reuxin]; [reuxin mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(4*imageHeight/12); make.height.mas_equalTo(imageHeight/12); make.right.mas_equalTo(0); }]; reuxin.tag=2; reuxin.backgroundColor=[UIColor clearColor]; [reuxin addTarget:self action:@selector(service:) forControlEvents:UIControlEventTouchUpInside]; UIButton*songnuo=[UIButton buttonWithType:UIButtonTypeSystem]; [self.imageView addSubview:songnuo]; [songnuo mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(8*imageHeight/12); make.height.mas_equalTo(imageHeight/12); make.right.mas_equalTo(0); }]; songnuo.tag=3; songnuo.backgroundColor=[UIColor clearColor]; [songnuo addTarget:self action:@selector(service:) forControlEvents:UIControlEventTouchUpInside]; } else if ([self.type isEqualToString:@"instruction"])//详细说明书 { UIButton*camera=[UIButton buttonWithType:UIButtonTypeSystem]; [self.imageView addSubview:camera]; [camera mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.height.mas_equalTo(imageHeight/7); make.right.mas_equalTo(0); }]; camera.tag=1; camera.backgroundColor=[UIColor clearColor]; [camera addTarget:self action:@selector(instruction:) forControlEvents:UIControlEventTouchUpInside]; UIButton*senven=[UIButton buttonWithType:UIButtonTypeSystem]; [self.imageView addSubview:senven]; [senven mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(imageHeight/7); make.height.mas_equalTo(1*imageHeight/7); make.right.mas_equalTo(0); }]; senven.tag=2; senven.backgroundColor=[UIColor clearColor]; [senven addTarget:self action:@selector(instruction:) forControlEvents:UIControlEventTouchUpInside]; UIButton*sw7=[UIButton buttonWithType:UIButtonTypeSystem]; [self.imageView addSubview:sw7]; [sw7 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(2*imageHeight/7); make.height.mas_equalTo(1*imageHeight/7); make.right.mas_equalTo(0); }]; sw7.tag=3; sw7.backgroundColor=[UIColor clearColor]; [sw7 addTarget:self action:@selector(instruction:) forControlEvents:UIControlEventTouchUpInside]; UIButton*sw10=[UIButton buttonWithType:UIButtonTypeSystem]; [self.imageView addSubview:sw10]; [sw10 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(3*imageHeight/7); make.height.mas_equalTo(1*imageHeight/7); make.right.mas_equalTo(0); }]; sw10.tag=4; sw10.backgroundColor=[UIColor clearColor]; [sw10 addTarget:self action:@selector(instruction:) forControlEvents:UIControlEventTouchUpInside]; UIButton*cw2=[UIButton buttonWithType:UIButtonTypeSystem]; [self.imageView addSubview:cw2]; [cw2 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(4*imageHeight/7); make.height.mas_equalTo(1*imageHeight/7); make.right.mas_equalTo(0); }]; cw2.tag=5; cw2.backgroundColor=[UIColor clearColor]; [cw2 addTarget:self action:@selector(instruction:) forControlEvents:UIControlEventTouchUpInside]; UIButton*sw1_6=[UIButton buttonWithType:UIButtonTypeSystem]; [self.imageView addSubview:sw1_6]; [sw1_6 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(5*imageHeight/7); make.height.mas_equalTo(1*imageHeight/7); make.right.mas_equalTo(0); }]; sw1_6.tag=6; sw1_6.backgroundColor=[UIColor clearColor]; [sw1_6 addTarget:self action:@selector(instruction:) forControlEvents:UIControlEventTouchUpInside]; UIButton*hxwy01=[UIButton buttonWithType:UIButtonTypeSystem]; [self.imageView addSubview:hxwy01]; [hxwy01 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(6*imageHeight/7); make.height.mas_equalTo(1*imageHeight/7); make.right.mas_equalTo(0); }]; hxwy01.tag=7; hxwy01.backgroundColor=[UIColor clearColor]; [hxwy01 addTarget:self action:@selector(instruction:) forControlEvents:UIControlEventTouchUpInside]; } } -(void)instruction:(UIButton*)button { self.hidesBottomBarWhenPushed = YES; InfoByImageViewController*info=[[InfoByImageViewController alloc]init]; if (button.tag==1) { info.title=@"常见失败原因"; info.image=[UIImage imageNamed:@"failreason"]; } else if (button.tag==2) { info.title=@"小7摄像头"; info.image=[UIImage imageNamed:@"cameraInfo"]; } else if (button.tag==3) { info.title=@"绚多SW7"; info.image=[UIImage imageNamed:@"SW7"]; } else if (button.tag==4) { info.title=@"绚多SW10"; info.image=[UIImage imageNamed:@"SW10"]; } else if (button.tag==5) { info.title=@"绚多CW2"; info.image=[UIImage imageNamed:@"CW2"]; } else if (button.tag==6) { info.title=@"绚多SW1/SW6/W6"; info.image=[UIImage imageNamed:@"sw1"]; } else if (button.tag==7) { info.title=@"睿芯HX-WY01"; info.image=[UIImage imageNamed:@"HX-WY01"]; } [self.navigationController pushViewController:info animated:YES]; } -(void)service:(UIButton*)button { NSURL*url; if (button.tag==1) { url=[NSURL URLWithString:@"tel://17321129273"]; } else if (button.tag==2) { url=[NSURL URLWithString:@"tel://4000121101"]; } else if (button.tag==3) { url=[NSURL URLWithString:@"tel://13392205468"]; } if (@available(iOS 10.0, *)) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; }else { [[UIApplication sharedApplication] openURL:url]; } } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end