我已经创建了一个协议和匹配的委托。 我定义的方法似乎没有触发,但没有错误。
ResourceScrollView.h
//Top of File
@protocol ResourceScrollViewDelegate
- (void)loadPDFWithItem:(NSString *)filePath;
@end
//Within Interface
id<ResourceScrollViewDelegate> _scrollViewDelegate;
//Outside Interface
@property (nonatomic, retain) id<ResourceScrollViewDelegate> scrollViewDelegate;
ResourceScrollView.m
//Inside Implementation
@synthesize scrollViewDelegate=_scrollViewDelegate;
//Within a button tapped method
[_scrollViewDelegate loadPDFWithItem:filePath];
ResourcesViewController.h
//Top of File
#import "ResourceScrollView.h"
@interface ResourcesViewController : UIViewController <ResourceScrollViewDelegate>
ResourcesViewController.m
//Inside Implementation
- (void)loadPDFWithItem:(NSString *)filePath{
NSLog(@"PDF %@",filePath);
}
由于某种原因,我没有得到NSLog。 没有错误或崩溃,它根本不会触发。
我是否有任何可以解释此行为的错误?
答案 0 :(得分:4)
您是否忘记将ResourcesViewController
对象设置为scrollViewDelegate
属性?