所以我有2個視圖控制器,並且希望DOAbrirListaViewController.h成爲AddTaskViewControoler.h的委託,理論上我認爲我有一切設置,但DOAbrirListaView上的方法永遠不會被調用。UIViewController代表團的子類
DOAbrirViewController.h
#import "AddTaskViewController.h"
@interface DOAbrirListaViewController : UITableViewController <NSFetchedResultsControllerDelegate, UIAlertViewDelegate, AddTaskViewControllerDelegate>
DOAbrirViewController.m
-(void)addTaskDidCancel {
NSLog(@"AddTask Did Cancel");
}
-(void)addTaskDidSave {
NSLog(@"AddTask Did Save");
}
AddTaskViewController.h
@protocol AddTaskViewControllerDelegate
-(void)addTaskDidSave;
-(void)addTaskDidCancel;
@end
@interface AddTaskViewController : UIViewController
@property (nonatomic, weak) id <AddTaskViewControllerDelegate> delegate;
@property (nonatomic, strong) CDMyLists *currentList;
@end
AddTaskViewController.m
- (IBAction)createButton:(id)sender {
[self.delegate addTaskDidSave];
NSLog(@"Create Button");
}
- (IBAction)cancelButton:(id)sender {
[self.delegate addTaskDidCancel];
NSLog(@"Cancel Button");
}
按鈕被點擊,但在addTaskDidSave
和AddTaskDidCancel
上的NSLOG,永遠不會被調用。
您是否設置了'委託'?或者它是'零'? –