0
votes

I have a view that has a set of messages that the user receives, I'm trying to accomplish a UX similar to how gmail works.

I want when a user taps on the user's image it selects the row for whatever action they want to do (delete, mark as read, etc) and then if they tap anywhere else it shows the message. Below is a basic proof of concept.

basic poc

I thought about setting up a tap gesture on the imageview but I feel like there's cleaner way than doing that and possibly something built into the table view, but I'm striking out.

1
You can set the style (such as background color) when you select a cell in method RowSelected . - Lucas Zhang - MSFT
I know that, but the problem is more that I want the selected state to do something based on where the user tapped. - Eddie
It's the same , you can handle the logic in it.. - Lucas Zhang - MSFT

1 Answers

0
votes

What you're trying to do is have separate tap functions depending on the location. You'll have to add separate tap actions on each part of your cell.

So, in the Source of your TableView, you have to update the override UITableViewCell GetCell so that it updates the Image Button and adds the ability to allow user interaction and add a single tap gesture.

public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
    var cell = tableView.DequeueReusableCell (cellIdentifier);
    // where cellIdentifier is you TableView Cell key

    if (cell == null)
        cell = new UITableViewCell (UITableViewCellStyle.Default, cellIdentifier);
    cell.TextLabel.Text = tableItems [indexPath.Row];

    // Add other generic code above, but here's what you need
    cell.ImageButton.UserInteractionEnabled = true;
    var singleTapGestureRecognizer = new UITapGestureRecognizer(() =>  // Do work
                                                                );
    cell.ImageButton.AddGestureRecognizer(singleTapGestureRecognizer);

    return cell;
}