我设置了以下简单的视图控制器类
@protocol ThermoFluidsSelectorViewControllerDelegate;
@interface ThermoFluidsSelectorViewController : UIViewController <UITextFieldDelegate>
@property (weak, nonatomic) id <ThermoFluidsSelectorViewControllerDelegate> delegate;
// user hits done button
- (IBAction)done:(id)sender;
@end
@protocol ThermoFluidsSelectorViewControllerDelegate <NSObject>
-(void) didFinishSelection:(ThermoFluidsSelectorViewController *)controller fluidID: (NSString *)fluidID;
@end
'didFinishSeletion: fluidID:' 方法在主视图控制器中定义,并且在调用时应该关闭选择器视图控制器。当按下完成按钮时,将调用以下方法:
- (IBAction)done:(id)sender
{
[[self delegate] didFinishSelection:self fluidID:nil];
}
'done:' 方法被调用(通过警报检查)但 'didFinishSelection...' 没有被调用,因此视图不会返回到主屏幕。有任何想法吗?