Suppose I have a nav controller stack with 2 view controllers: VC2 is on top and VC1 is underneath. Is there code I can include in VC1 that will detect that VC2 has just be
One way you could approach this would be to declare a delegate protocol for VC2 something like this:
in VC1.h
@interface VC1 : UIViewController {
...
}
in VC1.m
-(void)showVC2 {
VC2 *vc2 = [[VC2 alloc] init];
vc2.delegate = self;
[self.navigationController pushViewController:vc2 animated:YES];
}
-(void)VC2DidPop {
// Do whatever in response to VC2 being popped off the nav controller
}
in VC2.h
@protocol VC2Delegate
-(void)VC2DidPop;
@end
@interface VC2 : UIViewController {
id delegate;
}
@property (nonatomic, assign) id delegate;
...
@end
VC2.m
-(void)viewDidUnload {
[super viewDidUnload];
[self.delegate VC2DidPop];
}
There's a good article on the basics of protocols and delegates here.