0
我已经看过所有其他问题都有同样的问题,但我似乎无法听到我的消息。我很确定我已经做好了一切,因为这不是我第一次使用代表。代理方法没有被调用
//PDFView.h
@class PDFView;
@protocol PDFViewDelegate <NSObject>
-(void)trialwithPOints:(PDFView*)pdfview;
@end
@interface PDFView : UIView
@property (nonatomic, weak) id <PDFViewDelegate> delegate;
在实现文件中我试图打电话但从
//PDFView.m
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.delegate trialwithPOints:self];
}
其中委托方法实现
//points.h
#import "PDFView.h"
@interface points : NSObject <PDFViewDelegate>
//points.m
//this is where the delegate is set
- (id)init
{
if ((self = [super init]))
{
pdfView = [[PDFView alloc]init];
pdfView.delegate = self;
}
return self;
}
-(void)trialwithPOints:(PDFView *)pdf
{
NSLog(@"THE DELEGATE METHOD CALLED TO PASS THE POINTS TO THE CLIENT");
}
因此,这是怎样的类touchesMoved委托的委托方法我已经写了我的委托,不知何故委托是零,委托方法永远不会被调用。
目前我没有对委托做任何事情,我只是想看看它的工作。
任何意见,将不胜感激。
你在哪里设置代表? –
对不起,我编辑我的代码..我忘了复制代码,我设置代表。 – fftoolbar