我的自定义委托没有接到电话。这是我的设置。ViewController
有一个SliderView
对象,它是 的子类UIScrollView
:
幻灯片视图.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
幻灯片视图.m
#import "SliderView.h"
@implementation SliderView
@synthesize slideViewDelegate;
- (void) handleTap:(UITapGestureRecognizer *)recognizer{
NSLog(@"tapped");
[[self slideViewDelegate] didTapImageData: imageData atIndex:0 ];
}
视图控制器.h
@interface ViewController : UIViewController <
UIScrollViewDelegate,
SlideViewDelegate>{
SliderView *thumbGalleryView;//delegate and reference are set in XCode
}
视图控制器.m
#import "ViewController.h"
@implementation ViewController
-(void)didTapImageData:(NSMutableArray*) imageData atIndex:(int)index{
NSLog(@"NOT WORKING HERE");
}
所以ViewController
永远不会收到上述方法的电话。thumbGalleryView
链接到并且ViewController
委托也设置为ViewController
。SlideView
的handleTap
打印消息很好,但[[self slideViewDelegate] didTapImageData: imageData atIndex:0 ];
被忽略了。为什么?