【发布时间】:2013-08-01 01:03:21
【问题描述】:
我已经查看了具有相同问题的所有其他问题,但我似乎无法听到有关它的信息。我很确定我做的一切都是正确的,因为这不是我第一次使用代表。
//PDFView.h
@class PDFView;
@protocol PDFViewDelegate <NSObject>
-(void)trialwithPOints:(PDFView*)pdfview;
@end
@interface PDFView : UIView
@property (nonatomic, weak) id <PDFViewDelegate> delegate;
在实现文件中,我试图从视图的 touchesMoved 委托调用委托方法
//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");
}
所以这就是我编写委托的方式,不知何故委托为 nil,委托方法从未被调用。
目前我没有对代理做任何事情,我只是想看看它是否正常工作。
对此的任何建议将不胜感激。
【问题讨论】:
-
你在哪里设置代理?
-
对不起,我编辑了我的代码。我忘了复制我设置委托的代码。
标签: objective-c ios6 delegates xcode4.5