1
我正在研究一個iPad應用程序,我遇到了委託問題......協議方法沒有被調用。我不確定我錯過了什麼,這裏是我的代碼。協議方法沒有被調用,顯示委託'nil'
@protocol pickerLabelProtocol <NSObject>
- (void)selectedPickerData:(UILabel *)sender;
@end
@interface showPickerVC : UIViewController
@property (nonatomic, strong) id <pickerLabelProtocol> delegate;
@end
@implementation showPickerVC
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
//i used breakpoint, the 'delegate' is always nil for some reason?
[self.delegate selectedPickerData:self.mainLabel];
}
----------------------
@interface someViewController : UIViewController <pickerLabelProtocol>
@property (nonatomic, strong) showPickerVC *showPicker;
@end
@implementation someViewController
- (void)selectedPickerData:(UILabel *)sender
{
//protocol method
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.showPicker = [[showPickerVC alloc]init];
self.showPicker.delegate = self;
}
究竟是你想要做什麼?你想要訪問什麼? – Durgaprasad
「ShowPickerVC」是popOver,來自「someViewController」...「ShowPickerVC」有一個選擇器,用戶在選擇器中選擇數據,我希望選定的數據被傳遞給「someViewController」... – DevCali
我是不知道爲什麼,但這段代碼在iPhone中正常工作,但不與iPad可能是因爲popOver? – DevCali