下面這段代碼顯示圖片:
UIImageView *preArrowImage =[[UIImageView alloc]init ];
preArrowImage.image =[UIImage imageNamed:@"arrowprev.png"];
preArrowImage.frame = CGRectMake(20, 60, 10, 30);
[self.view addSubview:preArrowImage];
想要對preArrowImage 的觸控事件進行一些操作,怎麼實現?
給preArrowImage添加tap 手勢
UITapGestureRecognizer *recognizer=[[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(tapHandler:)];
[preArrowImage addGestureRecognizer:recognizer];
-(void)tapHandler:(UITapGestureRecognizer *)recognizer {
//...to do your logic
}