37

I'd like to change the order of view controllers attached to a UITabBarController, within my Storyboard, without disconnecting all view controllers and reconnecting them in the desired order.

My Question: Can this be done just via the Storyboard IB UI?

Discussion

I'm looking for some inspector panel where I can move items up and down in that list of view controllers that feeds the viewControllers property on UITabBarController.

several view controllers linked to tab bar controller

I've got a lot of tabs and so I'm hoping to not have to disconnect everything and reconnect, just to change the order.

I even tried changing the 'tag' value on the Bar Item, in the inspector, but that value was also ignored at runtime (I believe it is for identification purposes, not for ordering).

Tag set on Bar Item

idStar
  • 10,674
  • 9
  • 54
  • 57

7 Answers7

93

enter image description here

you can simply drag and drop and resort them with the mouse in the storyboard. it still works in 4.5.1

EDIT

maybe you have first to switch the storyboard view to "Source Code" and go back before you can drag. right-click the storyboard file and select "Open as" -> "Source Code" and then back again "Open as" -> "Interface Builder - iOS Storyboard". that should do the trick.

EDIT

Does not work in Xcode 4.5.2 anymore for me!

EDIT

In Xcode 5 preview 5 it works again. Seems that Apple did fix this bug in the new verion

enter image description here

rockstarberlin
  • 1,853
  • 1
  • 18
  • 31
  • Yup. More specifically, in case it helps: just drag the "tabs" around in the tab bar where it appears in the tab controller scene of the storyboard. – rickster Jul 02 '12 at 23:27
  • 1
    That was it! I was clicking and dragging everywhere else, as I thought I tried this in the past and it didn't work for me then. Glad that's solved. Thanks guys. – idStar Jul 02 '12 at 23:32
  • 1
    I used to do reorder in this way. But it doesn't work in Xcode 4.5.1. Any idea? Thanks – Bagusflyer Oct 06 '12 at 09:11
  • drag and drop where? In the storyboard? Where in the storyboard I should drag and drop? – user4951 Oct 10 '12 at 03:48
  • 36
    I can confirm: in XCode 4.5.1 you CANT drag and drop the tab UNTIL you view the storyboard as Source Code, then view again as Storyboard. Hey presto you can drag and drop – JulianB Oct 11 '12 at 14:51
  • i don´t know what you mean. source code of the storyboard? i even don´t know where to view it. i simply created a new project, selected Tabbed Application, saved the project, selected the storyboard and i can drag&drop as described. – rockstarberlin Oct 11 '12 at 22:32
  • 8
    Right click on the storyboard file, select 'Open As', then 'Source Code', then back to the normal storyboard ('Open As' and 'iOS Storyboard'. Doing this enabled the drag and drop for me. – Ted Oct 12 '12 at 10:21
  • ah ok. that sounds interesting. however i didn´t have to do that to be able to drag&drop. – rockstarberlin Oct 12 '12 at 19:24
  • Not seeing the issue on 4.5.1 with a new project (created with 4.5.1 of course) – mattyohe Oct 15 '12 at 14:44
  • JulianB was right. i just had the same issue with a new project with tabbarcontroller. but viewing the source code did just fix it. when going back to IB let me drag the items. – rockstarberlin Oct 15 '12 at 17:54
  • I can't get the 'open as source code' trick to work on Xcode 4.6. I've tried it a number of times. Any ideas? – Ben Clayton Apr 12 '13 at 11:38
  • 1
    Also, manipulating items within a view is not possible if zoom is not 100% (or thereabouts) – Martyn Davis Mar 26 '15 at 23:49
16

If drag-n-drop not working, there is another workaround. In Storyboard I just removed all the relationships from the UITabBarController and reconnected them in the right order.

brooNo
  • 506
  • 4
  • 8
  • all of a sudden my solution doesn´t work for me anymore. and it seems the only way so reorder is to delete and reconnect the viewcontrollers. – rockstarberlin Jan 30 '13 at 21:14
9

XCode 4.5.1

Not an empirical answer but I had the same problem..

I opened the storyboard as Source Code, reordered the

Then opened the storyboard as Interface Builder - iOS Storyboard

Nothing changed... but

I could then drag and drop the tabs

JulianB
  • 1,686
  • 1
  • 19
  • 31
  • i did same thing. i opened as source code, without changing anything i opened as IB again and Voila! its working now. I can drag and drop now. Strange. – Sam Sep 13 '13 at 14:56
3

I had the same issue. If I putted a new View Controller or new Navigation Controller in storyboard, drag and drop did not work in tab bar controller. I closed and reopened Xcode and drag and drop worked well another time.

Ziggy
  • 121
  • 1
  • 9
  • Ziggy may be right before you down vote him. It seems that an edit in certain places in the storyboard somehow 'releases' the ability to drag and drop – JulianB Oct 11 '12 at 14:26
  • I tried the "Open as Source Code" stuff from other answers and those didn't work. Restarting Xcode did. – Kenny Wyland Apr 30 '13 at 04:55
3

I've been having this problem in Xcode 4.6.3, but just discovered a way to reorder my tabs. Not sure if this applies to everybody, but in the navigation menu on the left side of the storyboard, if I expand the TabBarController it reveals the Tab Bar element. Once I've clicked on the Tab Bar, I am then able to drag and drop the tab icons in interface builder the way I would expect to.

Chiubaka
  • 801
  • 2
  • 11
  • 27
  • This works well for me in 4.6.3. Once you select the Tab Bar element, it zooms on it and then you can drag and drop to reorder. Thanks! – louielouie Aug 13 '13 at 02:21
1

You can rearrange by going to Source Code view and find the scene and edit the source. You can find the tab bar segue and add the code. (right-click on the storyboard in the project navigator and choose Open As...Source Code) Then go back to Storyboard Nib view (right-click on the storyboard in the project navigator and choose Open As...Interface Builder-IOS Storyboard)

1

After I added a new view controller, Xcode 4.6.2 wouldn't let me reorder tabs either. Simply clicking on one of my source code files, then clicking back on the storyboard file does the trick and I can edit the tab order again.

Chris Livdahl
  • 4,662
  • 2
  • 38
  • 33