// // InfoByImageViewController.m // Ifish // // Created by 祝发冬 on 2020/6/20. // Copyright © 2020 lianlian. All rights reserved. // #import "InfoByImageViewController.h" @interface InstructionCell : UITableViewCell @property (nonatomic, strong) NSDictionary *model; @property (nonatomic, strong) UIImageView *icon; @end @implementation InstructionCell -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { UIImageView*imageView=[[UIImageView alloc]initWithFrame:CGRectZero]; [self.contentView addSubview:imageView]; imageView.contentMode=UIViewContentModeScaleToFill; [imageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.bottom.mas_equalTo(0); make.right.mas_equalTo(0); }]; self.icon=imageView; } return self; } - (void)setModel:(NSDictionary *)model { _model=model; UIImage*image=[UIImage imageNamed:model[@"image"]]; if (image) { self.icon.image=image; } else { self.icon.image=nil; } } @end @interface InfoByImageViewController () @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) NSArray *dataArray; @property (nonatomic, assign) CGFloat rowHeight; @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"])//详细说明书 { // [self getTableData]; // [self creatTab]; // return; NSInteger count =9; CGFloat itemHeight=imageHeight/count; for (int i=0; i