title: Simple Delegate Between View Controller and UIView Isn't Working
body: <p>So I am using a simple delegate to access a function from a main view controller when a button is pressed on a subview that is generated as an overlay on top of the main view.  For some reason the function that is defined in the source view controller isn't being executed.  I have done this 100 times and feel like I am just missing something stupid.  Here is the code how come this isn't working? </p>
  
  <p>Source ViewController's.h:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "ProfileSettingsViewController.h"
  #import "ImageViewer.h"
  
  @interface ProfileViewController : UIViewController &lt;UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, subViewDelegate&gt;
  </code></pre>
  
  <p>Source viewController.m:</p>
  
  <pre><code>#import &lt;Parse/Parse.h&gt;
  #import &lt;QuartzCore/QuartzCore.h&gt;
  #import "ImageViewer.h"
  #import "ProfileViewController.h"
  
  @interface ProfileViewController () &lt;UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, subViewDelegate&gt;
  
  @end
  
  //where the ImageViewer object is defined    
  @implementation ProfileViewController
  {
      NSMutableArray *dataArray;
      ImageViewer *loadImageViewer;
  }
  
  //where the UIView is initialized
  - (void) handleImageTap:(UIGestureRecognizer *)gestureRecognizer
  {
      if ([gestureRecognizer view] == _profilePic)
      {
          loadImageViewer = [ImageViewer alloc];
          [loadImageViewer loadImageIntoViewer:self imageToLoad:_profilePic.image];
      }
      else if ([gestureRecognizer view] == _coverPhoto)
      {
  
      }
  }
  </code></pre>
  
  <p>Destination View's.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import &lt;QuartzCore/QuartzCore.h&gt;
  
  @protocol subViewDelegate
  -(void)photoFromSubview:(id)sender;
  @end
  
  @interface ImageViewer : UIView
  
  @property (nonatomic, assign) id &lt;subViewDelegate&gt; delegate;
  @property (nonatomic, copy) UIImage *mainImage;
  @property (nonatomic, copy) UIViewController *parentView;
  
  - (void)fromCameraRoll;
  - (void)takePhoto;
  - (void)removeImageViewer;
  - (void)captureImage:(id)sender;
  - (void)uploadPhoto:(id)sender;
  - (UIImage *)addBackground;
  - (ImageViewer *)loadImageIntoViewer:(UIViewController *)superView imageToLoad:(UIImage *)imageToLoad;
  
  @end
  </code></pre>
  
  <p>Destination View's.m</p>
  
  <pre><code>#import "ImageViewer.h"
  
  @implementation ImageViewer : UIView
  
  //synthesize properties
  @synthesize mainImage = _mainImage;
  @synthesize parentView = _parentView;
  
  //initialize the image viewer
  - (ImageViewer *)loadImageIntoViewer:(UIViewController *)superView imageToLoad:(UIImage *)imageToLoad
  {
      //create a new view with the same frame size as the superView
      ImageViewer *imageViewer = [[ImageViewer alloc] initWithFrame:superView.view.bounds];
      _mainImage = imageToLoad;
      _parentView = superView;
  
      //if something's gone wrong, abort!
      if(!imageViewer)
      {
          return nil;
      }
  
      //add all components and functionalities to the program
      UIImageView *background = [[UIImageView alloc] initWithImage:[imageViewer addBackground]];
      background.alpha = 0.85;
      [imageViewer addSubview:background];
      [imageViewer addSubview:[imageViewer addImageToView:_mainImage superView:superView.view]];
      [imageViewer addSubview:[imageViewer addButtonToView:(superView.view.bounds.origin.x + 10.0) yPos:(superView.view.bounds.origin.x + 10.0) buttonAction:@selector(back:) buttonTitle:@"Back"]];
      [imageViewer addSubview:[imageViewer addButtonToView:(superView.view.bounds.origin.x + 10.0) yPos:((superView.view.center.y/2) + 270.0) buttonAction:@selector(captureImage:) buttonTitle:@"Camera"]];
      [imageViewer addSubview:[imageViewer addButtonToView:(superView.view.bounds.origin.x + 105.0) yPos:((superView.view.center.y/2) + 270.0) buttonAction:@selector(uploadPhoto:) buttonTitle:@"Upload"]];
      [imageViewer addSubview:[imageViewer addButtonToView:(superView.view.bounds.origin.x + 200.0) yPos:((superView.view.center.y/2) + 270.0) buttonAction:@selector(rotatePhoto:) buttonTitle:@"Rotate"]];
      [superView.view addSubview:imageViewer];
  
      return imageViewer;
  }
  
  //call delegate method
  - (void)captureImage:(id)sender
  {
      [self.delegate photoFromSubview:self];
  }
  </code></pre>
  
  <p>I have screwed something up haven't I?</p>