iOS-Slide-Menu icon indicating copy to clipboard operation
iOS-Slide-Menu copied to clipboard

Bar buttons now update when changed

Open gdisco opened this issue 10 years ago • 3 comments

Love this subclass :). Had an issue while implementing it though: I created my SlideNavigationController using - initWithRootViewController (I don't use storyboards), and then I added a custom leftBarButtonItem, but the custom button wasn't showing up. I discovered that this is because the bar button items only update when a view controller is pushed onto the navigation stack. Since I was adding the custom button AFTER I added my root view controller, it wasn't getting updated. This patch overrides the setters on the bar button items such that they get updated whenever they're changed.

gdisco avatar May 24 '15 09:05 gdisco

Sorry been a while. Will look into this after I fix the landscape bug

aryaxt avatar Jul 02 '15 16:07 aryaxt

Yeah I can confirm this bug. If I add leftBarButtonItem in Storyboard and set an action outlet and do [[SlideNavigationController sharedInstance] toggleLeftMenu];, the leftBarButtonItem wouldn't show up. Also if I add it in AppDelegate using code:

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)]; [button setImage:[UIImage imageNamed:@"[email protected]"] forState:UIControlStateNormal]; [button addTarget:[SlideNavigationController sharedInstance] action:@selector(toggleLeftMenu) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button]; [SlideNavigationController sharedInstance].leftBarButtonItem = leftBarButtonItem;

This leftBarButton item also disappears. Only if you call above methods in viewdidload of a particular tabbar, the leftBarButtonItem would show up. This seems definitely like a bug.

coolcool1994 avatar Jun 21 '17 13:06 coolcool1994

Hey @aryaxt looks like this bug is still outstanding after all this time, and at least one other person would benefit from the fix! What do you say about merging in the pull request? Should be basically a no-op for you, github has verified there's no conflicts.

gdisco avatar Sep 07 '17 04:09 gdisco