ChatGPT解决这个技术问题 Extra ChatGPT

Rearranging Tab Bar Controller Order in StoryBoard

In my app iPhone app I have a Tab Bar Controller with 4 relationships to 4 different Table View Controllers. Is there a way to rearrange the order of the relationship in the StoryBoard graphically? I can't find a way to do this and I'm sure I must be missing something!


a
abitofcode

In 4.5 save the storyboard after adding a Controller, switch to another file and then back to the Storyboard and the tab dragging should work again.


Tab dragging ! Ok I didn't even know we could drag the tabs. Not very intuitive since tabs are not selectable...
If you get tired of poking at the Xcode UI with tab switch/close incantations just look at JannieT's answer. It's quick and easy.
Unintuitive but it worked for me as well in Xcode 7.
If you don't see items to drag, it could be because you haven't set an icon yet. I found that it wasn't showing up until I set the icons!
nice :) didn't even knew that it can be draggable
I
Indy Bains

You can just re-arrange the order by dragging and dropping the icons in the tab bar controller


If you are using custom tabs, you can still drag and drop to reorder even though the Tab Bar Controller scene shows a grey bar, the bar item is still there. This is especially inconspicuous when all your bar item are custom items.
Most straight-forward & convenient way. Works in Xcode 7.3.1. Swift 2.2
Works in Xcode 9 – though the icons were invisible.
h
handsome

SHIFT + DRAG works on Xcode 10.0


As simple as that.
Simple and works! Saved me a LOT of time! Thank you!
N
Nicola

I was not able to drag&drop with XCode 4.6 (with any of mentioned cobination). I have solved it opening the storybord in "Source Code" mode, locating the tabBarController and rearranging the seque tag.


I have a tab bar controller nested in a split view controller, and as a result, the tab bar controller's tabs are not visible in the storyboard. Editing the storyboard source code worked for me. Thanks!
S
Sixto Saez

I know the OP is using Xcode interface builder and asking for a graphical way to do this, but for developers working with Xamarin iOS Designer, here is a workaround that I use.

Open the .storyboard file in a text editor or using Xcode, right click on the storyboard item in Project Navigator and select Open As Source Code. In the storyboard XML locate the <tabBarController ...> node. Then I rearrange the order of the segues in the <connections> section:

<connections>
    <segue destination="274" kind="relationship" relationship="viewControllers" id="286"/>
    <segue id="943" destination="910" kind="relationship" relationship="viewControllers"/>
    <segue destination="147" kind="relationship" relationship="viewControllers" id="159"/>
</connections>

Search for the destination= attribute value in the XML to determine which view controller the segue element is pointing at.


Great solution. I had a huge StoryBoard and removing and recreating the segues would have taken some time
A
Aaban Tariq Murtaza

XCODE 10.1: Zoom the story board. Simply drag tab items. (No shift no other)


How did you think to try this? 😃 Brilliant! 👏
F
Fogmeister

Just drag and drop the tab icons in the tab bar.

i.e. the main tab bar that belongs to the tab bar controller.

HTH

::EDIT:: So this doesn't seem to work... I'm sure it used to.

Anyway, the easiest way I found is to remove the tabs and add them back in the order you want them to show.

Hope this helps.


LOL, just gone to test and I was wrong. Sorry. Have done this before though. One sec...
Yeah I think I remember that drag&drop did work even though I'm not sure about that! Maybe they changed something in Xcode..
I just tried it, and it worked fine to just drag the tabs in Xcode 4.5
@rdelmar did you start your project as a tab bar application or did you add a tab bar view controller to a single view application?
Drag & drop does work, but it gets stubborn if you've done anything in storyboard before trying to drag & drop the tabs. To fix it, select any other file in Xcode and then go back to your storyboard. Drag & drop will work again. No need to close Xcode or re-add your controllers.
b
bryfox

As noted in comments, drag & drop doesn't currently work (Xcode 4.5) after adding a navigation controller. However, restarting Xcode after adding the controller seems to get drag & drop working again.


T
Tom DeMille

If you open the storyboard as 'source code view' and then close it an open it as IB view it seems to fix the bug..


This worked for me (Xcode 8.1), I was able to finally drag to re-arrange after opening the storyboard in source code view.
G
Gerald

To add on to the drag and drop method provided by everyone. I posted this as an answer so that I can include images. Tried on Xcode 7.3

If you are using custom tab bar item, you can still drag and drop to reorder even though the Tab Bar Controller scene shows a grey bar, the bar item is still there. This is especially inconspicuous when all your bar item are custom items

https://i.stack.imgur.com/odw8g.png


M
Michael Osofsky

I'm using XCode 5.1 for development of iOS 7.1 and I found the following approach works for rearranging the tabs in a Tab Bar Controller.

To rearrange the tabs in a Tab Bar Controller, delete the segues from the Tab Bar Controller to your sub-view controllers. Then re-draw the segues in the order you want the tabs. To "re-draw" I mean you control drag from the Tab Bar Controller to the sub-view controller and select Relationship Segue (at bottom of list) => view controllers.


true. Another way of doing that is editing the .storyboard as "Source code", finding the segues (they are a tag), and re-arranging their order.
m
mohsen

You can just drag tab bar item and drop it in the place that you want, like the beneath picture

https://i.stack.imgur.com/wgchL.png


佚名

You can make sure that the Tab Controller Dock option in your Main storyboard is set to "First Responder", that solved it for me!


I've been trying out several of these ideas, as I'm now having this problem no matter what project I now bring up (new or old) . I can't figure out what KayKay means by "the Tab Controller Dock option". Anybody have any ideas?
W
Winter

I had the same issue after adding a Navigation Controller.

Fix: close the storyboard (Ctrl+Cmd+W) and do a clean build folder (Option+Cmd+Shift+K) and a regular clean (Cmd+Shift+K). Reopen the storyboard and you'll be able to drag the items again.


N
NANNAV

Same thing is in xCode 4.6. I originally was following tutorial on beginning storyboards in ios At the point to swith the item on TabBarController, I could't change the order. I tried to save it - didn't work; however, Once I closed the XCode and open again - it DID WORK.


S
Sreedeepkesav M S

Control + drag the item in TabBarController in storyboard and rearrange to the desired position.


i think it is Option + drag
R
Rachna Anil

I was following the raywenderlich tutorial for storyboards too and realised that after adding the tab controller i couldn't rearrange the tabs by dragging it. Well, apparently its just some bug in xcode. So just quit xcode, restart it and this time, you will be able to drag the tabs.


N
Nina

For me dragging did not work either in XCode 7.3.1. Restarting XCode did not help. And none of the above mentioned solutions worked for me.

What helped me: I deleted the relationship to the second item and ctrl-dragged from that item to the Tab Bar Controller and created another relationship. It was automatically in the second place now.


D
Digvijay Gida

Remove all viewcontrollers sequge with tabbar. You need first viewcontroller first segue then another viewcontroller connect with tabbar.

No restart xcode & no clear source code file in change require.