Reputation: 10348
Is there a way to implement your own mechanism to detect when dismissModalViewControllerAnimated disappears? I've tried viewdiddisappear, but this is not being called as I think it only called when subview are removed from a view. With the case of modals, I think iOS treats them differently.
Any ideas?
I would like my delegate to do some action after this modal view has been dismissed.
Thanks.
Upvotes: 1
Views: 518
Reputation: 3454
Use NSNotificationCenter to post a notification before you dismiss the view controller. Add your other view controllers as observers. That's an easy way to broadcast events.
So before you dismiss:
[[NSNotificationCenter defaultCenter] postNotificationName:@"DismissModalViewController"
object:nil];
[self dismissModalViewControllerAnimated:YES];
And then in your view controllers
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yourCallback)
name:@"DismissModalViewController"
object:nil];
The callback would be something like:
- (void) yourCallback
{
// some code to run when modal view controller is dismissed
}
Upvotes: 1
Reputation: 10348
I found the issue.
The view controller that made this call, I forgot to set who the delegate was.
Upvotes: 0
Reputation: 4473
You can use the parent view controller's viewWillAppear
. By parent view controller, I mean the receiver of presentViewController
(or presentModalViewController
)
Upvotes: 0
Reputation: 6803
Add a delegate method that is called right before dismissModalViewController
Upvotes: 0