I started testing ECSlidingViewController and after I tried to access FirstTopViewController
I have a big trouble - because in FirstToViewController
I already have ZBarReaderDelegate implemented and all examples of delegate are not triggering any method from my delegate.
Basically I have this stuff:
FirstTopViewController.h
#import ...MyStuff...
#import "UnderRightViewController.h"
@interface FirstTopViewController : UIViewController <RightViewDelegate, ZBarReaderDelegate>
@property (weak, nonatomic) IBOutlet UITextView *labelTotal;
@end
FirstTopViewController.m
#import "FirstTopViewController.h"
@implementation FirstTopViewController
- (void)setTotalViewController:(UnderRightViewController*)controller didTotalChange:(NSString*)total
{
//labelTotal.text = total;
NSLog(@"I'm here!!! and received %@", total);
}
From other side I have
UnderRightViewController.h
#import <UIKit/UIKit.h>
#import "ECSlidingViewController.h"
@class UnderRightViewController;
@protocol RightViewDelegate <NSObject>
- (void)setTotalViewController:(UnderRightViewController*)controller didTotalChange:(NSString*)total;
@end
@interface UnderRightViewController : UITableViewController
@property (nonatomic, weak) id <RightViewDelegate> delegate;
@end
UnderRightViewController.m
#import "UnderRightViewController.h"
@interface UnderRightViewController ()
@end
@implementation UnderRightViewController
@synthesize delegate;
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[delegate setTotalViewController:self didTotalChange:@"foo"];
}
@end
I'm trying this entire day solve this puzzle but I never get setTotalViewController
fired.
Thanks in advance.
Friend you did a small mistake, when you navigate from
FirstTopViewController
to UnderRightViewController at that time you need to do this in FirstTopViewController.m:-You don't have any code that is setting the delegate for the UnderRightViewController. I don't know what object owns both of these controllers, but before either UnderRightViewController and FirstTopViewController are displayed it should run code something like this:
In your above code you are using custom delegates and also you have used it for sending message to onecontroller class to another controller class. So below is the same sample code of custom delegates, it is working fine in similar way you have to implement and also the problem in your code is you are not setting the delegate, so please follow below how to set the same and call the method. here i have used your same method only return type i have defined as
NSString
in-spite ofvoid
for explaining purpose, but you can usevoid
according to your requirement hope it will be helpful to you:-First Controller Class
AWindowController.h
Second Controller Class
BWindowController.h
Attached screen shot in Output:- Below is window is the
AwindowController.h
classBelow in the same above window pressing the button and when Awindow button pressed data will send
and notification will be recieved in Bwindow using above define custom delegates as attached in the screen shot.