jessesquires / JSQMessagesViewController

An elegant messages UI library for iOS
https://www.jessesquires.com/blog/officially-deprecating-jsqmessagesviewcontroller/
Other
11.14k stars 2.81k forks source link

Avatar imageView tap visual feedback #424

Closed ghazel closed 10 years ago

ghazel commented 10 years ago

When tapping an avatar UIImageView, there is no visual feedback during the tap.

If the avatar was instead a UIButton, this would be handled automatically. In fact, casting a properly configured UIButton to UIImageView and returning it from avatarImageViewForItemAtIndexPath works pretty much as expected.

Three ways to implement this come to mind:

  1. let the user return a UIButton
    • changes the API
    • user has register an action and use indexPathForItemAtPoint to get the indexPath, which is a little pain
    • the long press recognizer for context menus must be configure to skip UIButtons
  2. UIButton inside JSQMessagesViewController
    • changes the api less
    • maybe requires a lot of copying of UIImageView properties from the user-supplied object to the readonly UIButton.imageView (ugg)
    • same longPress exception as option 1
  3. Manual mask on touchesBegan
    • need to get touchesBegan
    • find a way to emulate the UIButton mask to fit the user-supplied image view

So, how would you prefer this to work? Any other implementation ideas?

jessesquires commented 10 years ago

thanks @ghazel - This is on my list of things to do soon. I've also considered most of these options, but I'm not sure which I prefer yet...

ghazel commented 10 years ago

For my app, I chose (option 1) to return a UIButton. Maybe the API should go even farther and just accept any UIView. This seems the most customizable from a user perspective, if somewhat less convenient.

brbgyn commented 10 years ago

If it's a non specific task to be called, you can do this with just this:

imageView.userInteractionEnabled = YES; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarTap)]; [imageView addGestureRecognizer:tap];

and any touch on any avatar will call the selector you choose

ghazel commented 10 years ago

There is already a tap gesture recognizer that JSQ provides. The issue is that there is no visual feedback of the tap (grey mask applied to the image while the user's finger is down)

brbgyn commented 10 years ago

hmm right

jessesquires commented 10 years ago

Fixed by completing #319 and set for 6.0 release. See branch release-6.0.

See release 6.0 milestone details here