关于imageview 点击事件 IOSimageView点击事件图片显示app 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 - (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //导航栏 self.navigationItem.title=@"BookShelf Demo"; //背景图片设置 UIImage *backgroundImage=[UIImage imageNamed:@"bg_cork.png"]; UIColor *backgroundColor=[UIColor colorWithPatternImage:backgroundImage]; [self.ImageView setBackgroundColor:backgroundColor]; [self.view insertSubview:self.ImageView aboveSubview:0]; //编辑按钮 self.navigationItem.leftBarButtonItem=self.editButtonItem; //大小and位置 bookimage[0]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65, 93, 114)]; bookimage[0].image = [UIImage imageNamed:@"A1.jpeg"]; //图片显示 bookimage[0].hidden=NO; //点击事件 bookimage[0].userInteractionEnabled=YES; UITapGestureRecognizer *click0=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[0] addGestureRecognizer:click0]; [self.ImageView addSubview:bookimage[0]]; NSLog(@"A1"); [bookimage[0] release]; bookimage[1]=[[UIImageView alloc]initWithFrame:CGRectMake(114, 65, 93, 114)]; bookimage[1].image = [UIImage imageNamed:@"A2.jpeg"]; bookimage[1].hidden=NO; bookimage[1].contentMode=UIViewContentModeScaleToFill; bookimage[1].userInteractionEnabled=YES; UITapGestureRecognizer *click1=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[1] addGestureRecognizer:click1]; [self.ImageView addSubview:bookimage[1]]; [bookimage[1] release]; bookimage[2]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65, 93, 114)]; bookimage[2].image = [UIImage imageNamed:@"A3.jpeg"]; bookimage[2].hidden=NO; bookimage[2].contentMode=UIViewContentModeScaleToFill; bookimage[2].userInteractionEnabled=YES; UITapGestureRecognizer *click2=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[2] addGestureRecognizer:click2]; [self.ImageView addSubview:bookimage[2]]; [bookimage[2] release]; bookimage[3]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65+114+12, 93, 114)]; bookimage[3].image = [UIImage imageNamed:@"A4.jpeg"]; bookimage[3].hidden=NO; bookimage[3].contentMode=UIViewContentModeScaleToFill; bookimage[3].userInteractionEnabled=YES; UITapGestureRecognizer *click3=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[3] addGestureRecognizer:click3]; [self.ImageView addSubview:bookimage[3]]; [bookimage[3] release]; bookimage[4]=[[UIImageView alloc]initWithFrame:CGRectMake(114,65+114+14 , 93, 114)]; bookimage[4].image = [UIImage imageNamed:@"A5.jpeg"]; bookimage[4].hidden=NO; bookimage[4].contentMode=UIViewContentModeScaleToFill; bookimage[4].userInteractionEnabled=YES; UITapGestureRecognizer *click4=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[3] addGestureRecognizer:click4]; [self.ImageView addSubview:bookimage[4]]; [bookimage[4] release]; bookimage[5]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65+114+14, 93, 114)]; bookimage[5].image = [UIImage imageNamed:@"A6.jpeg"]; bookimage[5].hidden=NO; bookimage[5].contentMode=UIViewContentModeScaleToFill; bookimage[5].userInteractionEnabled=YES; UITapGestureRecognizer *click5=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[3] addGestureRecognizer:click5]; [self.ImageView addSubview:bookimage[5]]; [bookimage[5] release]; bookimage[6]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65+(114+14)*2, 93, 114)]; bookimage[6].image = [UIImage imageNamed:@"A7.jpeg"]; bookimage[6].hidden=NO; bookimage[6].contentMode=UIViewContentModeScaleToFill; bookimage[6].userInteractionEnabled=YES; UITapGestureRecognizer *click6=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[6] addGestureRecognizer:click6]; [self.ImageView addSubview:bookimage[6]]; [bookimage[6] release]; bookimage[7]=[[UIImageView alloc]initWithFrame:CGRectMake(112, 65+(114+14)*2, 93, 114)]; bookimage[7].image = [UIImage imageNamed:@"A8.jpeg"]; bookimage[7].hidden=NO; bookimage[7].contentMode=UIViewContentModeScaleToFill; bookimage[7].userInteractionEnabled=YES; UITapGestureRecognizer *click7=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[7] addGestureRecognizer:click7]; [self.ImageView addSubview:bookimage[7]]; [bookimage[7] release]; bookimage[8]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65+(114+14)*2, 93, 114)]; bookimage[8].image = [UIImage imageNamed:@"A9.jpeg"]; bookimage[8].hidden=NO; bookimage[8].contentMode=UIViewContentModeScaleToFill; bookimage[8].userInteractionEnabled=YES; UITapGestureRecognizer *click8=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[8] addGestureRecognizer:click8]; [self.ImageView addSubview:bookimage[8]]; [bookimage[8] release]; bookimage[9]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65+(114+14)*3, 93, 114)]; bookimage[9].image = [UIImage imageNamed:@"A10.jpeg"]; bookimage[9].hidden=NO; bookimage[9].contentMode=UIViewContentModeScaleToFill; bookimage[9].userInteractionEnabled=YES; UITapGestureRecognizer *click9=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[9] addGestureRecognizer:click9]; [self.ImageView addSubview:bookimage[9]]; [bookimage[9] release]; bookimage[10]=[[UIImageView alloc]initWithFrame:CGRectMake(112,65+(114+14)*3, 93, 114)]; bookimage[10].image = [UIImage imageNamed:@"A11.jpeg"]; bookimage[10].hidden=NO; bookimage[10].contentMode=UIViewContentModeScaleToFill; bookimage[10].userInteractionEnabled=YES; UITapGestureRecognizer *click10=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[10] addGestureRecognizer:click10]; [self.ImageView addSubview:bookimage[10]]; [bookimage[10] release]; bookimage[11]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65+(114+14)*3, 93, 114)]; bookimage[11].image = [UIImage imageNamed:@"A12.jpeg"]; bookimage[11].hidden=NO; bookimage[11].contentMode=UIViewContentModeScaleToFill; bookimage[11].userInteractionEnabled=YES; UITapGestureRecognizer *click11=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)]; [bookimage[11] addGestureRecognizer:click11]; [self.ImageView addSubview:bookimage[11]]; [bookimage[11] release];}- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}-(void)setEditing:(BOOL)editing animated:(BOOL)animated{ [super setEditing:editing animated:animated]; if(editing) { NSLog(@"编辑状态"); }else { NSLog(@"非编辑状态"); }}//内存释放- (void)dealloc { [_ImageView release]; [super dealloc];}@end ios 切图,先谢了! 弱弱地问一下,iphone中如何调用自定义方法... IOS创建线程问题 关于 CCGameBox引擎的问题 线程导致模拟器CPU占用很高 ithmb文件的格式头?? 问大家一下关于苹果的授权芯片和lighting接口数据传输协议哪里可以找到? iOS开发中两层view上的button不响应点击事件怎么解决 h5与IOS进行数据传值 iOS 为什么添加在ScrollView上的button在我滑动ScrollView后, button的点击事件就失效了 tableview 全选问题 ios7 下照片库的使用时取消使用照片后导致状态栏不见
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//导航栏
self.navigationItem.title=@"BookShelf Demo";
//背景图片设置
UIImage *backgroundImage=[UIImage imageNamed:@"bg_cork.png"];
UIColor *backgroundColor=[UIColor colorWithPatternImage:backgroundImage];
[self.ImageView setBackgroundColor:backgroundColor];
[self.view insertSubview:self.ImageView aboveSubview:0]; //编辑按钮
self.navigationItem.leftBarButtonItem=self.editButtonItem;
//大小and位置
bookimage[0]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65, 93, 114)];
bookimage[0].image = [UIImage imageNamed:@"A1.jpeg"];
//图片显示
bookimage[0].hidden=NO;
//点击事件
bookimage[0].userInteractionEnabled=YES;
UITapGestureRecognizer *click0=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[0] addGestureRecognizer:click0];
[self.ImageView addSubview:bookimage[0]];
NSLog(@"A1");
[bookimage[0] release];
bookimage[1]=[[UIImageView alloc]initWithFrame:CGRectMake(114, 65, 93, 114)];
bookimage[1].image = [UIImage imageNamed:@"A2.jpeg"];
bookimage[1].hidden=NO;
bookimage[1].contentMode=UIViewContentModeScaleToFill;
bookimage[1].userInteractionEnabled=YES;
UITapGestureRecognizer *click1=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[1] addGestureRecognizer:click1];
[self.ImageView addSubview:bookimage[1]];
[bookimage[1] release];
bookimage[2]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65, 93, 114)];
bookimage[2].image = [UIImage imageNamed:@"A3.jpeg"];
bookimage[2].hidden=NO;
bookimage[2].contentMode=UIViewContentModeScaleToFill;
bookimage[2].userInteractionEnabled=YES;
UITapGestureRecognizer *click2=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[2] addGestureRecognizer:click2];
[self.ImageView addSubview:bookimage[2]];
[bookimage[2] release];
bookimage[3]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65+114+12, 93, 114)];
bookimage[3].image = [UIImage imageNamed:@"A4.jpeg"];
bookimage[3].hidden=NO;
bookimage[3].contentMode=UIViewContentModeScaleToFill;
bookimage[3].userInteractionEnabled=YES;
UITapGestureRecognizer *click3=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[3] addGestureRecognizer:click3];
[self.ImageView addSubview:bookimage[3]];
[bookimage[3] release];
bookimage[4]=[[UIImageView alloc]initWithFrame:CGRectMake(114,65+114+14 , 93, 114)];
bookimage[4].image = [UIImage imageNamed:@"A5.jpeg"];
bookimage[4].hidden=NO;
bookimage[4].contentMode=UIViewContentModeScaleToFill;
bookimage[4].userInteractionEnabled=YES;
UITapGestureRecognizer *click4=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[3] addGestureRecognizer:click4];
[self.ImageView addSubview:bookimage[4]];
[bookimage[4] release];
bookimage[5]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65+114+14, 93, 114)];
bookimage[5].image = [UIImage imageNamed:@"A6.jpeg"];
bookimage[5].hidden=NO;
bookimage[5].contentMode=UIViewContentModeScaleToFill;
bookimage[5].userInteractionEnabled=YES;
UITapGestureRecognizer *click5=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[3] addGestureRecognizer:click5];
[self.ImageView addSubview:bookimage[5]];
[bookimage[5] release];
bookimage[6]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65+(114+14)*2, 93, 114)];
bookimage[6].image = [UIImage imageNamed:@"A7.jpeg"];
bookimage[6].hidden=NO;
bookimage[6].contentMode=UIViewContentModeScaleToFill;
bookimage[6].userInteractionEnabled=YES;
UITapGestureRecognizer *click6=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[6] addGestureRecognizer:click6];
[self.ImageView addSubview:bookimage[6]];
[bookimage[6] release];
bookimage[7]=[[UIImageView alloc]initWithFrame:CGRectMake(112, 65+(114+14)*2, 93, 114)];
bookimage[7].image = [UIImage imageNamed:@"A8.jpeg"];
bookimage[7].hidden=NO;
bookimage[7].contentMode=UIViewContentModeScaleToFill;
bookimage[7].userInteractionEnabled=YES;
UITapGestureRecognizer *click7=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[7] addGestureRecognizer:click7];
[self.ImageView addSubview:bookimage[7]];
[bookimage[7] release];
bookimage[8]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65+(114+14)*2, 93, 114)];
bookimage[8].image = [UIImage imageNamed:@"A9.jpeg"];
bookimage[8].hidden=NO;
bookimage[8].contentMode=UIViewContentModeScaleToFill;
bookimage[8].userInteractionEnabled=YES;
UITapGestureRecognizer *click8=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[8] addGestureRecognizer:click8];
[self.ImageView addSubview:bookimage[8]];
[bookimage[8] release];
bookimage[9]=[[UIImageView alloc]initWithFrame:CGRectMake(1, 65+(114+14)*3, 93, 114)];
bookimage[9].image = [UIImage imageNamed:@"A10.jpeg"];
bookimage[9].hidden=NO;
bookimage[9].contentMode=UIViewContentModeScaleToFill;
bookimage[9].userInteractionEnabled=YES;
UITapGestureRecognizer *click9=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[9] addGestureRecognizer:click9];
[self.ImageView addSubview:bookimage[9]];
[bookimage[9] release];
bookimage[10]=[[UIImageView alloc]initWithFrame:CGRectMake(112,65+(114+14)*3, 93, 114)];
bookimage[10].image = [UIImage imageNamed:@"A11.jpeg"];
bookimage[10].hidden=NO;
bookimage[10].contentMode=UIViewContentModeScaleToFill;
bookimage[10].userInteractionEnabled=YES;
UITapGestureRecognizer *click10=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[10] addGestureRecognizer:click10];
[self.ImageView addSubview:bookimage[10]];
[bookimage[10] release];
bookimage[11]=[[UIImageView alloc]initWithFrame:CGRectMake(226, 65+(114+14)*3, 93, 114)];
bookimage[11].image = [UIImage imageNamed:@"A12.jpeg"];
bookimage[11].hidden=NO;
bookimage[11].contentMode=UIViewContentModeScaleToFill;
bookimage[11].userInteractionEnabled=YES;
UITapGestureRecognizer *click11=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageView)];
[bookimage[11] addGestureRecognizer:click11];
[self.ImageView addSubview:bookimage[11]];
[bookimage[11] release];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
if(editing)
{
NSLog(@"编辑状态");
}else
{
NSLog(@"非编辑状态");
}
}//内存释放
- (void)dealloc { [_ImageView release];
[super dealloc];
}
@end