I am following this tutorial on adding a sidebar navigation to an app.
In the given source code they have provided the storyboard layouts pre-defined. One of them is a view that has a "Navigation Item" and a "Bar Button Item" which appears on the left of the top navigation bar.
I am trying to do the same in my app, however the button item keeps automatically appearing on the right, and I cannot find any way to move it to the left.
I noticed, in the example provided in the tutorial, it gives this outlet option leftBarButton option:
And when I check mine, it looks like this:
There is no navigation controller because of how SWRevealView works. When I run the app, I can see the button and it works perfectly, only issue is it's on the right hand side. I've compared my view with the example, and cannot seem to find any difference.
Any help is appreciated.
EDIT This might help. In storyboards, this is what the working example looks like:
And this is what mine looks like
Drag BarButtonItem and place left side on your navigation item.
You can also add left hand side buttons by code:
NSMutableArray *leftBtns = [[NSMutableArray alloc] init];
UIBarButtonItem *leftBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"LeftButton"] style:UIBarButtonItemStylePlain target:self action:@selector(leftButtonPressed)];
[leftBtns addObject:leftBtn];
[self.navigationItem setLeftBarButtonItems:leftBtns animated:NO];
// method
-(void)leftButtonPressed
{
NSLog(@"Left Button Tapped");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With