Change class of TabBar in xCode4 - uitableview

I'm following the following tutorial that was made in xCode3
http://www.youtube.com/watch?v=LBnPfAtswgw
As I'm using xCode4, I followed everything until the part where she changed the class of the first tab to UINavigationController as I didn't got that option! Please help.
Regards,
Ali

You can do it without having to delete and drag new controllers in:
To change the type of an object:
From within Xcode 4, open your .xib file. If the interface builder object viewer isn't expanded, make it so by dragging it's right boarder out, or clicking that little 'play' button at the bottom.
Expand the Tab Bar Controller object to see it's children, and select the object you wish to change
Then choose it's Class type from the right panel, Identity Inspector. (To display the Identity Inspector, go menu: View > Utilities > Identity Inspector).
You can open and close that right panel using the buttons on the top right of Xcode. You can get to the various utilities by clicking the utility buttons, or through View > Utilities.
To rearrange tabs in the Tab Bar Controller, drag and drop them in the interface builder object viewer (this will change their position in the actual tab bar too).

I found alternative solution by deleting the default created tabs and drag new controllers which have the classes I need in my app.

Related

Use Storyboard References While Retaining Icons & Text for Tab Bar Controller

I started refactoring one of my projects to make the code easier to manage and the Tab Bar Controller lost its icons for which tab represents what. Without this I'm a bit lost which tab is what for re-ordering purposes.
How do I get the icons to show up again for a tab bar controller when I'm using storyboard references?
Refer to my attached image. Notice how the first 3 tabs are 'blank' but the other tabs that I have not refactored yet show with the icons and titles.
For those unfamiliar with storyboard references I was following the tutorial here: http://code.tutsplus.com/tutorials/ios-9-staying-organized-with-storyboard-references--cms-24226
Sample of Tasks Storyboard to show Icon set Correctly
It seems another solution that worked for me without altering the Approach you went through:
Leave Storyboard references as it's
Go to Initial view controller in the referenced storyboard
Add Tab bar item to the scene
Configure it as you have done in UITabBarController storyboard
Clean & Run
Repeat it for all Storyboard references
Happy Coding!
First, in the storyboard where the tab bar controller is, there should be a scene for the referenced storyboard.
Just click on the scene that tab is associated with and click the tab bar at the bottom, then go to the attributes inspector, and you'll be able to assign a new icon to it.
Update - This approach no longer appears to work in Xcode 9.
Here's how to get the tab to show properly:
Put the first UIViewController that will be embedded in the tab in
the same storyboard as the UITabViewController.
Ctrl + Drag from the tab bar controller to the content view
controller to make the connection as per usual. This will
automatically add the UITabBarItem to the bottom of the content view
controller.
Select the content view controller.
Click the Editor menu and choose Refactor to Storyboard...
The UITabBarController tab will now point to the new storyboard
reference...
... and the content view controller preserves the UITabBarItem from
the tab bar relationship. It will appear normally in the app now.
For some weird reason, I wasn't able to see the tab bar in my reference view controller in IB. Although while selecting it and expanding the Document Outline, I was able to see it in my view list. I could make my changes through it.
Hope this helps! :)
XCode 11.1: The following approach gets the desired tab title and icon to show at runtime:
Create a storyboard reference to the desired storyboard (including the correct bundle identifier if it is located in an external framework).
Ctrl-drag from the tab bar controller to the reference you just created and select "Relationship Segue > view controllers" from the context menu that appears.
The tab bar should now show a square image with the title "Item" beside it. Click and drag this item to rearrange it in the bar as desired.
In the target view controller (which should be the first responder in the referenced storyboard), create a Tab Bar Item and set the Title and Image properties in the Bar Item section of the properties panel.
At this point, the correct title should appear at runtime (but not at compile time in the storyboard editor). If the icon is there too, great. If it's not, you can try checking that the image reference is valid and located in the same module as the tab bar item (i.e. in the same framework). If it still doesn't appear, here's a hackish workaround that will work:
Create a new class which inherits from UITabBarController.
Override viewWillLayoutSubviews as follows:
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
// Set the tab bar image at runtime
if let exampleTab = tabBar.items?.first(where: { $0.title == "ExampleTitle" }) {
// To insert an image literal, type "Image" and select Image Literal
// from the autocomplete menu. An icon should appear.
// Double-click the icon and select the desired image from the grid.
exampleTab.image = Image Literal
}
}
Change the type of your tab bar controller to the subclass you created (from the Identity panel in the storyboard editor).
Finally, the tab bar item should now appear correctly at runtime. If anyone knows how to make it appear correctly at compile time too (in the storyboard editor) for a storyboard in an external framework, let me know.
If you embed a navigation controller before your scene, you then can edit it like normal.
Select your storyboard reference then:
Go to the top and click Editor > Embed > Navigation Controller
Tab bar controller with embedded navigation controller and linking storyboard reference

Can't select tab bar items, greyed out tab bar

My nav bar is completely greyed out. I've seen some solutions like this saying that you should simply add an image to the tab bar item. I can't even select a tab bar item...see screen below.
Any ideas? I'm running Xcode 7.2, using Swift with a BaaS (Parse). I've searched for hours/days and can't figure this one out...May sound like a dumb question, but every other example I search essentially shows a tab bar with items that you can select/edit within the interface builder. As I can't figure out how to select a tab bar item within the interface builder, I've essentially been stuck. Do I need to do this all programmatically (I know some people have preference here), or can it be done in interface builder?
I add them as has been mentioned (using a view controller relationship segue, images below), but after I add it, everything is still greyed out and I don't have any tab bar items. Any ideas?
control-click action, using relationship segue under view controller
everything is greyed out, no tab bar items available to edit or add images to
Ok, here we go. You have a Tab Bar created.
Drag a View Controller to your storyboard. Place it next to your Tab Bar.
Ctrl-click on the Tab Bar and drag it to the View Controller.
Select the option like the image below.
About this this you must see the item on your tab bar. Click on it and you'll be able to edit (choose an image, change the label...).
Hope that helps.

Xcode how do I duplicate a View Controller? I've had this complication for days

How do I duplicate View Controllers, so I don't have to re-place the menu screen in my UI, because it stays constant throughout each screen.
Somebody told me to copy this:
However 'View Controller Scene' is not in my project navigator...
So they told me: "You have to right click in your project navigator and create a new file. Select "Cocoa Touch Class" and create a subclass of UIViewController."
I did exactly that, but it gives me code files, not a 'View Controller Scene' in which I can copy the 'View Controller' in order to have two of the same on my storyboard.
I am using Objective C, and I have had this problem for days, can somebody PLEASE help me out?
In your first photo, where you have the "View Controller" highlighted, click on the left arrow to open the view hierarchy. Select the view that comprises your menu and hit Command + D or Edit > Duplicate.
This will create a duplicate version of your menu in the same ViewController. Grab the duplicated copy and move it to any other scene you want in your Storyboard
EDIT: You're looking at the wrong menu. Click on your Main.storyboard and then in the bottom Left of the Storyboard, click the little menu icon that opens the Document Outline. Alternatively, go to Editor > Show Document Outline when Main.storyboard is selected

Tabs and webView

It will become clear as you read that I have very little experience programming please excuse me for an elementary question. I have on the storyboard the template for a tab based app. which has two view controllers both of which have a web view on them and both seem to be working fine. As I needed a third tab I dragged a view controller onto the storyboard and linked it to the tab bar controller, I also created a "thirdViewContoller.swift" file which was copied from one of the other two which was in the template. Ran the app and everything works fine. I now drag a UiWebView onto the third view controller and unlike the other two when I try to control drag the webView to the code it will not link up. What am I missing. Many thanks for any help.
Did you check that your thirdViewController class is set in the storyboard? Click the yellow circle on your third view controller that you added in the storyboard. Go to the Identity inspector tab. Make sure the "Custom class:" field is set to thirdViewController. Now you should be able to make an IBOutlet for your web view by control dragging.

How to re-order segues in initial view's tabbar controller in xcode 4.5?

How do I reorder the initial view's tabbar controller elements without having to delete all the segues and re connect them manually in the desired order? Is there a way to change the order of these after they have been hooked up?
I was able to do this by just dragging them around in xcode 4.4 but that option seems to be non available in xcode 4.5.
Hopefully, this is possible from within the storyboard mode. But if it's only possible programmatically, that's ok too, just looking for any proper way to accomplish this without having to delete them all and re hook them up.
For example, how would I move the 'Home' item to first position?
The positions in each view are associated with the positions on the bottom bar of the Tab Bar Controller. If you reorder that bar you will reorder your views. You can reorder them by drag and drop on your interface builder.
In your example just select Home in your Tab Bar Controller and drag it to the first position.
If you have problems dragging and dropping try to select first your Tab View Controller or exit your XCode and open it again (like #thepumpkin1979 and #Rick pointed out).
Just edit the xml file and it will work.
Click on your "storyboard" and click the most right of the 3 buttons in "Editor".
This will show up an xml file on the left which u can edit anyway you wish.
Inside that file you should see xml tag "tabBar", inside it is "items", inside this is "tabBarItem".
All your tabBar items will be listed. You may cut and paste them in the order you wish.
I just did it now in Xcode 4.5.2.
Hope it also works for you too.
Ps. I am new to iOS so I can't use all the right Xcode names.
I think you can control+drag the tab item to reorder.
Drag and drop should work
You can drag the bar Item to the left to rearrange its position from the Storyboard.

Resources