I have two controller class named TEnterCorrectCodeController and TEmergencyCancelController.
In Both the classes there are buttons.On the button click of both controller class I am calling another controller class name TSendEmailController. But problem is when the button click of TEnterCodecontroller is called it opens TSendEmailController through [self presentModalController] and on the click of button present in TsendEmail class I want another class to be opened.
When the button of TEmergencyCancelController is clicked it opens TsendEmail through [self presentModalController] and when the button of TsendEmail is clicked it should not open other class instead it should dismiss controller. The problem is how to identify which class has called TsendEmailController and depending on that I have to check the condition .problem is that I am not using navigationcontroller I am using [self presentModalViewController animated:YES] to push view.
This is my code:
for (int i=0; i< [self.navigationController viewControllers count]; i++)
{
UIViewController *aController = [[self.navigationController view viewControllers]objectAtIndex:i];
if ([aController isKindOfClass:[TEnterCorrectCodeController class]])
{
lblAttempt.hidden = YES;
[self saveregisteridinplist];
TInstructionsController *instructions = [[TInstructionsController alloc]init];
[self presentModalViewController:instructions animated:YES];
[instructions release];
}
else if ([aController isKindOfClass:[TEmergencyCancelController class]])
{
lblAttempt.hidden = YES;
[self saveregisteridinplist];
[self dismissModalViewControllerAnimated:YES];
}
}
In my code that I have written it does not get into for loop because I am not using navigationController.
For your solution of identifying which class has called
TsendEmail, define oneNSIntegerinAppDelegate.For ex.
NSInteger flag=0;…@property and @synthesizeit…..Now, when you call
TSendEmailfromTEnterCorrectCodeController, then setflagto 1……and inviewDidLoad of viewWillAppearmethod, setflagto 0….Now, when you are in
TEmergencyCancelControllerclass, check whetherflagis 0 or 1…if 0 then dissmiss your view…..You may use this concept….:)