4thSpace
4thSpace

Reputation: 44352

Why does BarButton go to bottom of view?

I have a ViewController. There is a NavigationController in the app. When I drag a Bar Button Item to the navigation bar, the item usually goes to the bottom of the ViewController. Although in the past, I have managed to get it to stick to the top right, where it is supposed to go.

Any idea why this sometimes works and sometimes not? Also, why does it go to the bottom? Going to the bottom does not follow the HIGs.

enter image description here

Upvotes: 3

Views: 875

Answers (3)

Kaushik Shanmugam
Kaushik Shanmugam

Reputation: 21

If that doesn't work, select root view controller->Attributes Inspector->Top Bar -> Opaque Navigation Bar. Tested and worked. Xcode7

Upvotes: 1

Naishta
Naishta

Reputation: 12373

I faced the same issue too. The fix is, Select the Navigation Controller.( the border of the controller changes to blue) In the right menu, select 'Attributes Inspector' You should see a 'Top Bar' menu item. Select 'Opaque Navigation Bar' in the dropdown Now add the bar button item to the top right/left navigation bar, it should work.

Tested and works in xcode 7

Upvotes: 2

Duyen-Hoa
Duyen-Hoa

Reputation: 15784

Besure that your ViewController is under a NavigationViewController.

Then, you have to insert first a Navigation Item into your Navigation Bar then add your BarButtonItem. I see that in Interface Builder, we can add only 1 BarButtonItem on the left and 1 BarButtonItem on the right.

Upvotes: 4

Related Questions