自定义委托方法未被调用

时间:2017-07-16 20:10:12

标签: ios objective-c delegates

我已按如下方式设置自定义委托,但未调用委托方法。我想知道在以下实施中我缺少什么。

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

0 个答案:

没有答案