0

我创建了一个协议和匹配的委托。我定义的方法似乎没有触发,但没有抛出任何错误。

资源滚动视图.h

//Top of File
@protocol ResourceScrollViewDelegate
    - (void)loadPDFWithItem:(NSString *)filePath;
@end
//Within Interface
id<ResourceScrollViewDelegate> _scrollViewDelegate;
//Outside Interface
@property (nonatomic, retain) id<ResourceScrollViewDelegate> scrollViewDelegate;

资源滚动视图.m

//Inside Implementation
@synthesize scrollViewDelegate=_scrollViewDelegate;
//Within a button tapped method
[_scrollViewDelegate loadPDFWithItem:filePath];

资源视图控制器.h

//Top of File
#import "ResourceScrollView.h"
@interface ResourcesViewController : UIViewController <ResourceScrollViewDelegate>

资源视图控制器.m

//Inside Implementation
- (void)loadPDFWithItem:(NSString *)filePath{
    NSLog(@"PDF %@",filePath);
}

出于某种原因,我没有收到 NSLog。没有错误或崩溃,它根本不会触发。

我是否犯了任何可能导致这种行为的错误?

4

1 回答 1

4

您是否忘记将ResourcesViewController对象设置为scrollViewDelegate属性?

于 2012-04-23T08:46:39.767 回答