Reputation: 37078
I'm just trying to set up a simple storyboard. I have a View Controller
embedded in a Navigation Controller
, and it is the starting view for the app. I added a full-page Table View
and a Table View Cell
inside that.
Then I wanted to add two Bar Button Items
to the top, but when I drag them in, that's where the trouble is. When I drag it onto the top bar, it creates a new bar at the bottom and attaches there instead. When I go to the Document Outline and manually drag it under Navigation Item
in the View Controller
, then it works and goes to the upper right.
But then there's no way for me to add a second Bar Button Item
to the upper left-- when I drag one in, it goes to the bottom, and if I try dropping it under Navigation Item
in the Document Outline along with the first one, it just ceases to exist, as though only one Bar Button Item
were allowed.
What am I doing wrong? This has worked fine in the past.
Upvotes: 1
Views: 765
Reputation: 2894
Sometimes storyboards have bad days and xCode has bugs. Then code comes to rescue:
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
showCalendar.frame = CGRectMake( 0, 0, 40, 30 );
[showCalendar setImage:[UIImage imageNamed:@"calendar"] forState:UIControlStateNormal];
[showCalendar addTarget:self action:@selector(METHOD CALL) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
You can repeat the process for adding another button on the left.
Upvotes: 1