My custom delegate does not receive a call. Here is my setup. ViewController has a SliderView object which is a subclass of UIScrollView:
SlideView.h
#import <UIKit/UIKit.h>
@protocol SlideViewDelegate <NSObject
@required
-(void) didTapImageData:(NSMutableArray*)imageData atIndex:(int)index;
@end
@interface SliderView : UIScrollView<UIGestureRecognizerDelegate> {
__weak id<SlideViewDelegate> slideViewDelegate;
}
@property (nonatomic, weak) id<SlideViewDelegate> slideViewDelegate;
@end
SlideView.m
#import "SliderView.h"
@implementation SliderView
@synthesize slideViewDelegate;
- (void) handleTap:(UITapGestureRecognizer *)recognizer{
NSLog(@"tapped");
[[self slideViewDelegate] didTapImageData: imageData atIndex:0 ];
}
ViewController.h
@interface ViewController : UIViewController <
UIScrollViewDelegate,
SlideViewDelegate>{
SliderView *thumbGalleryView;//delegate and reference are set in XCode
}
ViewController.m
#import "ViewController.h"
@implementation ViewController
-(void)didTapImageData:(NSMutableArray*) imageData atIndex:(int)index{
NSLog(@"NOT WORKING HERE");
}
So ViewController never receives a call at the method above. The thumbGalleryView is linked to ViewController and delegate is set to ViewController too. SlideView‘s handleTap is printing message fine but [[self slideViewDelegate] didTapImageData: imageData atIndex:0 ]; is ignored. Why?
You have set the
delegatewhich isivarof scroll view.You have to set the
slideViewDelegatetoViewControllerEdited
Add
IBOutletThen from your xib connect

slideViewDelegatetoViewControllerAlso remember to change the class of scroll view to
SliderViewAdded Image for clarity