我试图调用委托方法但是没有工作。我的错误在哪里?
这是我声明@protocol,delegate和方法的类:
#import "EEBaseVC.h"
@protocol EEInterstitialScreenDelegete;
@interface EEInterstitialScreen : EEBaseVC
@property(nonatomic,strong) id <EEInterstitialScreenDelegete> delegete;
@end
@protocol EEInterstitialScreenDelegete <NSObject>
-(void)interstitialScreenUpdateInfo:(EEInterstitialScreen *)interstitialscreen;
@end
这是另一个ViewController中委托方法的声明:
#pragma mark - EEInterstitialScreenDelegate
-(void)interstitialScreenUpdateInfo:(EEInterstitialScreen *)interstitialscreen
{
NSLog("hello");
}
我必须做一些事情来在前一个视图控制器中调用此方法。但if条件不满足:
if (_delegete && [_delegete respondsToSelector:@selector(interstitialScreenUpdateInfo:)] ) {
[_delegete interstitialScreenUpdateInfo:self];
}
答案 0 :(得分:1)
AnotherViewController * obj = [AnotherViewController alloc]init];
obj.delegate =self;
[self.navigationController pushViewController:obj];