我正在尝试委托,但它不起作用。changeView_ShowContact 方法将使视图控制器正常显示。但是当我从另一个类调用 changeView_ShowContact 时,它不会工作。
@protocol callingActions_fromMainNavigation <NSObject>
- (IBAction)changeView_ShowContact:(id)sender;
@end
**@interface Navigation_Main : NSViewController**
@property (nonatomic, strong) id <callingActions_fromMainNavigation> delegate;
**@implementation Navigation_Main**
@synthesize delegate;
- (IBAction)changeView_ShowContact:(id)sender;
{
NSLog(@"********************ShowContact");
AddStuffViewController = [[pageContact alloc] initWithNibName:@"pageContact" bundle:nil];
[AddStuffView addSubview:[AddStuffViewController view]]; //<This call here works ok.
}
.
@interface contacts : NSObject <callingActions_fromMainNavigation>
**@implementation contacts**
-(void)myMethodCall:(id)sender;
{
Navigation_Main *NavMain = [[Navigation_Main alloc] initWithNibName:@"Navigation_Main.h" bundle:nil];
[NavMain setDelegate:self];
[self changeView_ShowContact:nil];
//I need to call the (IBAction)changeView_ShowContact in the Main Navigation. This
//code is not working.
}
- (IBAction)changeView_ShowContact:(id)sender;
{
}