Skip to content

Instantly share code, notes, and snippets.

@ajonnet
Created April 9, 2016 11:53
Show Gist options
  • Save ajonnet/01eccb2272feaaed1c1aaa0290c721bc to your computer and use it in GitHub Desktop.
Save ajonnet/01eccb2272feaaed1c1aaa0290c721bc to your computer and use it in GitHub Desktop.
NavigationController BackButton Title hider
#import <Foundation/Foundation.h>
@interface NavCtlrBackTitleHider : NSObject <UINavigationControllerDelegate>
@end
#import "NavCtlrBackTitleHider.h"
@interface NavCtlrBackTitleHider ()
{
UINavigationControllerOperation operationType;
}
@end
@implementation NavCtlrBackTitleHider
#pragma mark - UINavigationControllerDelegate methods
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if (operationType == UINavigationControllerOperationPush) { //Pushing
UIViewController *fromVC = navigationController.viewControllers[navigationController.viewControllers.count - 2];
UINavigationItem *navItem = fromVC.navigationItem;
//Override the BackButton Item
UIBarButtonItem *backBt = [[UIBarButtonItem alloc] initWithTitle:@""
style:UIBarButtonItemStylePlain
target:nil
action:nil];
navItem.backBarButtonItem = backBt;
}else if(operationType == UINavigationControllerOperationPop){ //Popping
}else { //Presenting RootViewController
}
}
- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC
{
operationType = operation;
return nil;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment