0

所以我有一个问题。有人可以告诉我这行代码调用(协议)方法的问题吗

 [self.delegate poplogin];

poplogin 是方法名称,由于某种原因它不起作用。它没有调用方法poplogin

以供参考 :

@property(nonatomic,retain) id<loginAuthDelegate> delegate;

所以让我解释一下这个案子

所以可以说我有一个类 abc.h

@protocol loginAuthDelegate <NSObject>
-(void)poplogin;
@end

接口后

@property(nonatomic,retain) id<loginAuthDelegate> delegate;

in .m i am just calling the Delegate and @synthesize it
[self.delegate poplogin];

not i have another files
let say def.h
i am importing the Class abc.h
@interface def : UIViewController<loginAuthDelegate>



def.m
-(void)poplogin
{
NSLog(@"Delegate doesn't respond to here");
vmpaSecureLogin *ivc = [[vmpaSecureLogin alloc] init];
ivc.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:ivc animated:YES];
}
4

1 回答 1

2

这可能是self.delegate因为nil.

您可能忘记将您的对象影响delegate到您实现委托方法的其他对象,例如您的 ViewController 或其他东西。

于 2012-10-03T16:49:40.817 回答