我不知道爲什麼我的委託方法沒有被調用。下面是我的代碼。請告訴我我犯了什麼錯誤。 我已經完成了所有的設置,我相信我犯了一個愚蠢的錯誤。我的委託方法沒有被調用。任何幫助將不勝感激委託方法不叫
LSFiveViewController.h
@protocol OneToOne;
@protocol OneToOne <NSObject>
@optional
-(void)dismissPopOverlsfive;
@end
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "TimeTableViewController.h"
@class TimeTableViewController;
@interface LearningSessionFiveDetailsViewController : UIViewController<UITextFieldDelegate>
{
NSString *bookingString;
}
@property(nonatomic,weak)id<OneToOne>OneToOne;
@end
**LSFiveViewController.m**
@synthesize sessionAndDateLabelObj,OneToOne
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (IBAction)BookSingleSessionAction:(id)sender
{
if (self.OneToOne && [self.OneToOne respondsToSelector:@selector(dismissPopOverlsfive)])
{
[self.OneToOne dismissPopOverlsfive];
}
}
@end
TimeTableViewController.h
#import "OneToOneViewController.h"
#import "LearningSessionFiveDetailsViewController.h"
//other codes
@property(nonatomic,strong)LearningSessionFiveDetailsViewController *LSFiveObj;
@end
TimeTableViewController.m
#import "TimeTableViewController.h"
#import "LearningSessionFiveViewController.h"
#import "UIAlertView+Blocks.h"
- (void)viewDidLoad
{
LSFiveObj=[[LearningSessionFiveDetailsViewController alloc]init];
self.learnSearchFiveClassObj.OneToOne=self;
}
-(void)dismissPopOverlsfive
{
This method is not being called
}
您是否在任何地方使用'setDelegate:'? – 2014-11-21 13:56:06
self.learnSearchFiveClassObj.OneToOne = self; 這部分代碼將作爲「集合委託」工作 – iOSDeveloper 2014-11-21 13:58:50
嘗試將「< OneToOne >」添加到「TimeTableViewController」。嘗試檢查「如果」中的哪一項測試爲否。 – Larme 2014-11-21 14:05:59