0

I've added an image view, that is loaded by SDWebImage, to a tool bar.

...
[imgv setImageWithURL:[NSURL URLWithString: url] placeholderImage:[UIImage imageNamed:@"loading.png"]];
 UIBarButtonItem *userpicture = [[UIBarButtonItem alloc] initWithCustomView:imgv];

I want image view to response to user tap action. But I read from below link that it's not possible to apply setTarget and setAction methods to custom image views.

https://stackoverflow.com/a/2796488/1320039

How could I make the image view, that is located in tool bar, response user actions.

Community
  • 1
  • 1
zontragon
  • 780
  • 1
  • 9
  • 27

1 Answers1

0

As explained the question you linked, setTarget and setAction methods don't work as they're supposed to. But, what you can do is to add a UITapGestureRecognizer to your imageview and you'll be able to handle tap event.

limon
  • 3,222
  • 5
  • 35
  • 52