title: Delegate from button tap inside custom uitableviewcell
body: <p>I have read the Apple docs and I have trolled these forums and I have (successfully) done some tutorials and made my own delegates and I <strong><em>still</em></strong> do not understand something.  I am sure that it is something I am spacing off but since I have done due diligence and still don't know what I'm doing wrong I was hoping one of you would be able to tell me.</p>
  
  <p>The situation:</p>
  
  <p>I have a custom UITableViewCell that has a button in it.  When the button is tapped I am trying to pull up the UIImagePickerController form a delegate of this custom cell.  I can trap and respond to the button tap no problem but the flow never goes to the delegate method.  In other words, when I step through the code everything is fine until I try to step from the button target method to the delegate method in the second class.  It just never gets called.</p>
  
  <p>Here's the code.</p>
  
  <p>In the interface file for the custom cell I set the id for the delegate, set up the IBOutlet for the UIButton, and set the protocol method:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @protocol CustomPicCellDelegate;
  
  @interface CustomPicCell : UITableViewCell &lt;UITextInputTraits&gt; {
  
      UIButton *picButton;
      ...
      id&lt;CustomPicCellDelegate&gt; cellDelegate;
  }
  
  @property (nonatomic, retain) IBOutlet UIButton *picButton;
  ...
  @property (nonatomic, assign) id&lt;CustomPicCellDelegate&gt; cellDelegate;
  ...
  - (IBAction)getAPic;
  
  @end
  
  @protocol CustomPicCellDelegate &lt;NSObject&gt; 
  - (void)getPhoto;
  @end
  </code></pre>
  
  <p>The UIButton is hooked up to the getAPic method in IB.</p>
  
  <p>In the implementation file for the custom cell I put the method that the UIButton targets on touch up inside and attempt to call the delegate method in the delegate:</p>
  
  <pre><code>#import "CustomPicCell.h"
  
  @implementation CustomPicCell
  @synthesize cellDelegate;
  
  ...
  
  - (IBAction)getAPic {
      NSLog(@"You are here ...");
  
      if (cellDelegate &amp;&amp; [cellDelegate respondsToSelector:@selector(getPhoto)]) {
          [cellDelegate getPhoto];
      }
  }
  </code></pre>
  
  <p>In the delegate class interface I set it as the delegate for the custom cell:</p>
  
  <pre><code>@interface DelegateClass : UIViewController &lt; ... CustomPicCellDelegate&gt; {
  ...
  </code></pre>
  
  <p>In the delegate class implementation I attempt to pull the UIImagePickerController:</p>
  
  <pre><code>- (void)getPhoto {
      UIImagePickerController *picker = [[UIImagePickerController alloc] init];
      picker.delegate = self;
  
      picker.sourceType = UIImagePickerControllerSourceTypeCamera;
  
      [self presentModalViewController:picker animated:YES];
  }
  
  - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo (NSDictionary *)info {
      [picker dismissModalViewControllerAnimated:YES];
  }
  </code></pre>
  
  <p>I can not figure out why the delegate never gets called!  Please understand I'm sure that I have missed something but I have been over the docs and these forums many times and I can not find what I am doing wrong.  I am using delegates in other parts of the code just fine.  This one spot does not work.  Can anyone show me what I am fat-fingering?
  Thanks</p>