我已按如下方式设置自定义委托,但未调用委托方法。我想知道在以下实施中我缺少什么。
ComboSetViewController.h
/
ComboSetViewController.m
@protocol ComboSetViewControllerDelegate <NSObject>
@required
- (void)comboSelected;
@end
@interface ComboViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, weak) id <ComboSetViewControllerDelegate> comboSelectedDelegate;
@end
HomeViewController.h
- (IBAction)doneBtnClicked
{
selectedCombo.orderProductItemArray = comboOrderItemArray;
[comboSelectedDelegate comboSelected];
[self dismissViewControllerAnimated:YES completion:nil];
}
HomeViewController.m
#import "ComboViewController.h"
@interface HomeViewController : UIViewController<ComboSetViewControllerDelegate>
编辑:如果我在- (void)viewDidLoad {
[super viewDidLoad];
ComboViewController *comboViewController = [[ComboViewController alloc] init];
comboViewController.comboSelectedDelegate = self;
}
// is not getting called
-(void)comboSelected
{
NSLog(@"Combo Selected");
}
中分配了delegate
,那就可以了。
prepareSegue