Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding an interactive view to a MonoTouch.Dialog UITableViewCell
    primarykey
    data
    text
    <p>I'm trying to customise the <a href="https://github.com/xamarin/monotouch-samples/tree/master/BubbleCell" rel="nofollow">BubbleCell sample</a> in Xamarin's MonoTouch samples set. I want to add a UIImageView into the chat bubbles, and make it so when the UIImageView is tapped, the code can do something (in my case, open up a modal view - although for now I'll settle for writing something to the output window).</p> <p>The sample uses MonoTouch.Dialog to lay out the interface, and has a custom cell class that constructs the view and adds it to the UITableViewCell.ContentView.</p> <p>I've managed to get the UIImageView into the cell fairly easily. However, I can't seem to work out how to make the UIImageView respond to taps.</p> <p>I'm doing the construction of the UIImageView in the constructor of BubbleCell (in Bubble.cs), and at the same time, I add the following lines in:</p> <pre><code>var tap = new UITapGestureRecognizer(); tap.AddTarget( () =&gt; { Console.WriteLine("I'll do something here"); }); imageView.UserInteractionEnabled = true; imageView.AddGestureRecognizer(tap); </code></pre> <p>The code compiles and runs fine, but when I tap the UIImageView, nothing happens.</p> <p>I've tried a few changes, none of which fixed this:</p> <ul> <li>I swapped out the UIImageView for a custom UIButton.</li> <li>I went through the superview hierarchy of both the cell and the UITableView and made sure all of the superviews have the UserInteractionEnabled properties set to true. They do.</li> <li>I removed the UITapGestureRecognizer and tried subclassing UIImageView and intercepting the TouchesBegan/TouchesEnded methods (they were never called)</li> </ul> <p>Is there anything special I need to do to make the table cells within MonoTouch.Dialog work with user interaction?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload