Today I will conduct a test to look at the behavior of the native UINavigationBar . I created a simple piece of code that does the following:
- (void)pushController { PHViewController *ctrl2 = [[[PHViewController alloc] initWithNibName:@"PHViewController" bundle:nil] autorelease]; ctrl2.shouldShowPrompt = YES; [self.viewController pushViewController:ctrl2 animated:YES]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. PHViewController *ctrl = [[[PHViewController alloc] initWithNibName:@"PHViewController" bundle:nil] autorelease]; ctrl.shouldShowPrompt = YES; ctrl.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Push" style:UIBarButtonItemStyleDone target:self action:@selector(pushController)] autorelease]; self.viewController = [[[PHNavigationController alloc] initWithRootViewController:ctrl] autorelease]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; }
Now I have subclassed the UINavigationBar this UINavigationController (I know this is illegal, this is an educational question), and I have redefined the following methods:
- (void)setItems:(NSArray *)items animated:(BOOL)animated { NSLog(@"Setting Navigation Item"); [super setItems:items animated:animated]; } - (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated { NSLog(@"Pushing Navigation Item"); [super pushNavigationItem:item animated:animated]; } - (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated { NSLog(@"Poping Navigation Item"); return [super popNavigationItemAnimated:animated]; } - (void)setValue:(id)value forKeyPath:(NSString *)keyPath { NSLog(@"Setting Value: %@ for keyPath:%@", value, keyPath); [super setValue:value forKeyPath:keyPath]; }
Here is my question: why is the "Navigation Point Guidance" present in the console (hence the method being called) and the "Press Navigation Element" not?
Pier-olivier thibault
source share