【发布时间】:2012-10-03 16:46:01
【问题描述】:
所以我有一个问题。 有人能告诉我这行代码调用(协议)方法的问题吗
[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];
}
【问题讨论】:
-
你确定 delegate 不是 nil 吗?
标签: objective-c ios objective-c-protocol