我有AViewController.h
如下:
@interface AViewController : UIViewController
@end
@interface BViewController : AViewController;
- (void)MethodB;
@end
@interface CViewController : BViewController;
@end
然后我有AViewController.m
如下
@implementation AViewController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"AViewController.viewWillAppear");
}
@end
@implementation BViewController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"BViewController.viewWillAppear");
}
- (void)MethodB
{
NSLog(@"show MehtodB");
}
@end
@implementation CViewController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated]; <--*** I want this line to call AViewController.viewWillAppear directly ***
NSLog(@"CViewController.viewWillAppear");
[self MethodB];
}
当我们运行时,我们将得到如下日志:
2013-08-14 17:37:05.205 P1[12876:c07] AViewController.viewWillAppear
2013-08-14 17:37:05.206 P1[12876:c07] BViewController.viewWillAppear
2013-08-14 17:37:05.206 P1[12876:c07] CViewController.viewWillAppear
2013-08-14 17:37:05.207 P1[12876:c07] show MehtodB
但需要的应该是:
2013-08-14 17:37:05.205 P1[12876:c07] AViewController.viewWillAppear
2013-08-14 17:37:05.206 P1[12876:c07] CViewController.viewWillAppear
2013-08-14 17:37:05.207 P1[12876:c07] show MehtodB