I (think) I have researched this problem extensively in Apple's docs and online, both here and elsewhere. However, after several hours of troubleshooting I am out of ideas. My Modal view controller refuses to dismiss itself at the appropriate time.
I am aware that modal controllers must be dismissed by the controller that presented the modal view, and as far as I can tell, that's what I am doing.
The problem:
This is the code contained in prepareForSegue for the presenting viewcontroller, in its entirety:
if ([segue.identifier isEqualToString:@"DISCREPANCYVC"]) {
DiscrepancyViewController *destController = segue.destinationViewController;
destController.discrepancyDelegate = self;
}
The modal controller contains two UIPickerViews, which are behaving properly. The picker views are used to construct "classificationString", an NSString.
I have a "Done" button on the modal view, which, when pressed, calls this method/selector (as per the protocol definition that I've set up):
[self.DiscrepancyDelegate didFinishWithClassification:classificationString];
The didFinishWithClassification method appears as follows:
- (void)didFinishWithClassification:(NSString *)classification {
[self dismissModalViewControllerAnimated:NO];
If it matters, the protocol is defined as
@protocol DiscrepancyViewControllerDelegate <NSObject>
@required
- (void)didFinishWithClassification:(NSString *)aClassification;
@end
The property that holds the reference back to the presenting view appears as:
@property (strong, nonatomic) id <DiscrepancyViewControllerDelegate> DiscrepancyDelegate;
There are four additional properties (strong, nonatomic) which are used to house the four arrays that populate the UIPickerViews (each picker has two components).
I have tried both animated and non-animated dismissals with no change in behaviour.
What could be causing this? I am using ARC, so it's not up to me to release anything before trying to dump the modal screen, correct? And from what I have read, viewDidUnload() will not necessarily fire in this situation (and it is not firing in my case).
Help!!
Thx,
Ted