How to replace the FirstViewController in a TabBar app with another view controller (Kal)? - objective-c

I created an empty iPad TabBar application using XCode 4, without storyboards. I placed that app in a workspace. I then added the Kal source (obtained from the iPad Juice build) to the workspace as a separate project. The initial build was clean.
I then went to the Kal example (NativeKal) and added EventKitDataSource.h and .m, and NativeCalAppDelegate.h and .m. (The image below shows what files are in the example project)
This is the code from the NativeCalAppDelegate.h file:
I tried setting the first TabBar UIView controller to "KalViewController" as I would normally do when using Storyboards, but it isn't listed in the drop down list of classes.
The question is: how do I get the NativeCal example view controller to replace FirstViewController in the in my TabBar application?

Comments added as Answer.
My recommendation is to switch to storyboards it is a lot easier to do UITabBarControllers in them. You can do this by just creating a new storyboard and copy and paste everything into it and then control drag from the UITabBarController to the UIViewControllers that you want to be linked to the tab bar controller and it does the rest for you, everything else is the same after that. In storyboards you can set the first view controller to be loaded so if you need it to be KalController then you can set it when you set up the UITabBarController. You can also set this in the code. I found that storyboards were a great new feature to xcode, UITabBarCotrollers are a lot easier to do in them then in .nib files I could never get them to work.
Hope this has helped.

Related

Integrating a Nib based SQL3 Lite project into a tabbed bar

I have been looking around for a while and finally found a SQL Lite tutorial that perfectly suits my needs. I downloaded the source code from it.
This code however had plenty of depreciated code that I in turn fixed. Here is a link to my updated project. (HERE)
I have had quite a bit of experience integrating xib based projects into a tab bar project. But I'm stuck right at the beginning because in just about every file in this project there is a reference to SQLAppDelegate which is the app delegate of the SQL Project.
The problem I am having is that I have a storyboard project and already have an app delegate. If I included the code from SQLAppDelegate.h and SQLAppDelegate.m in my AppDelegate.h and AppDelegate.m of the storyboard project and include the code from RootViewController in the Tutorial project into my storyboard tabbar project view controller files and deleted RootViewController.xib and kept the rest of the files in my project, would that work?
E.g I would get rid of SQLAppDelegate.h and SQLAppDelegate.m and MainWindow.xib in the tutorial and integrate that code into my storyboard Appdelegate.h and AppDelegate.m.
Then I would take all the other files in the tutorial project and include then in my project with the correct frameworks. I would delete RootViewController.xib and keep RootViewController.h and .m , Then I would Integrate the setup of RootViewController.xib into my Tab I wanted it in my Tabbar storyboard. and make the correct references to it.
I would call that tab RootViewController in my storyboard.
I know I can include .xib files in my storyboard tabbar project and reference them from my storyboard. It works I've done it.
Would including the code inside SQLAppDelegate into my AppDelegate interfere with the code in the rest of my tabs?
Or can I just include SQLAppDelegate and the rest of the files into my project and reference them then delete MainWindow and _window code from my project and then make the relevant in my tab storyboard project connect to SQLAppDelegate?
This mite sound a bit confusing?
UPDATE
Okay... after trying to integrate it myself I came across a number of issues like
SQLAppDelegate *appDelegate = (SQLAppDelegate *)[[UIApplication sharedApplication] delegate];
Does not work in Arc and all in all I got about 10 errors and all I did was include the files within the tutorial project in my Storyboard tabbar project.
Who would have thought trying to use SQLite in a Storyboard Tabbar project was so difficult?
Is there any example of a Storyboard Tabbar Example out there that uses SQLite in one of the tabs?
The functionality of this project was so perfect. Sigh.
I found a Christmas Kepper App from raywenderlich.com/6603/basic-security-in-ios-5-tutorial-part-2 . A great tutorial, I downloaded the tutorial and aside from a few lines of depreciated code and 1 warning which I managed to fix, It works perfectly for what I want. :D

linking header and main files to story board xcode

I am pretty new to xcode and for the life of me I cannot figure this one out. I am adding a view controller to a storyboard and I am trying to add a picker to that controller, I have the code in a header and main file I created but how do I link those files to the viewcontroller in my storyboard?
Here is how:
Create a custom UIViewController subclass for your code, eg MyViewController.h and MyViewController.m
in the storyboard drag out a ViewController
(i think you have done both of these steps)
in the Identity Inspector (panel 3 of left-hand side Utilities panels), under 'Custom Class' you should see your class in the scrolling list. Select it.
Then you will want to make links between your picker in the storyboard and your code....

SIGABRT error when setting Tab Bar View Controller to custom view controller

I have been developing an iPhone application using the Detail View template. At some point I realized that I wanted my application to have a Tab Bar View controller as the root view controller. It seems that you do not want to push a tab bar view controller onto a navigation view controller. So I decided to start a new tab bar project and migrate my existing application code over. I thought this would be easiest.
So I have done that and the project builds without a problem. But I cannot seem to reassign the tab bar view controllers to ones which I already have. So I am replacing, "FirstViewController" with one of my custom ones. When I attempt to run the application it calls:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
And bombs with a SIGABRT error. I'm not sure why this is. I cannot see what the default view controller (firstviewcontroller) is implementing that my custom view controller is not.
Can anyone give me some ideas of what I should check?
Thanks!
update
It seems that my problem is related to the fact that my custom viewcontroller is of type UITableViewController. If I change this to be of type UIViewController it seems to work.
Update
I added a Navigation controller to the storyboard and created a relationship from it to a blank TableViewController. Then I assigned this TableViewController to my custom UITableViewController class. This seems to work. I'm not sure what plumbing was missing before.

UINavigationController inside UITabBarController - Two Navigation Bars?

Here are the steps I've followed - pretty much this: http://www.youtube.com/watch?v=cFNtD098Bbk&feature=player_embedded
Create new Tab Bar Application
Looking at MainWindow.xib I drag a UIViewController in
Drag one of the tabs View Controllers onto the UIViewController
Set up buttons and actions top push the new view
Note I have no idea how he did the last step in the video, dragging one tab object onto another won't work for me
The navigation works fine, the new view gets pushed and all that jazz. But when I go to the tab that has the navigation controller it has two navigationBar's.
I can't find where to get rid of this for the life of me. It must be something really simple but I've been searching for way too long.
None of the many tutorials I've found have this problem, not does the project files of those tutorials even though my project looks pretty much the same as theirs in IB.
Does anyone know how I can get rid of the useless navigation bar?
I'm using Xcode version 4.0.1
Not sure how I missed it but the answer was stupidly simple.
Just needed to delete the UIToolbar from the nib file, can't believe I didn't find that earlier.

Extracting nibs/xibs from storyboards (iOS)

I have created a simple project with a storyboard, and now realize that they don't support iOS 4.x and that I would like users with these devices to be able to download my app. The app is just a flipside view controller, and is fairly simple but if there's a way to just extract the XIBs from the storyboard I'd much prefer to do that than recreate it.
tl;dr: getting .xibs out of a .storyboard?
Xib files cannot be extracted from the storyboard but you can instantiate UIViewControllers out of the storyboard by instantiating your storyboard into a UIStoryboard Object and getting the UIViewController via its identifier, here's how I do it:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
#"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
UIViewController *myController = [storyboard instantiateViewControllerWithIdentifier:#"myId"];
hope this helps.
I found that the simplest method was to copy and paste the items out of the storyboard, one view at a time, and recreate the view controllers for each one.
However, for anybody who does this, note that you have to make a xib for MainWindow in addition to all of your other XIBs, and hook it up accordingly, including setting up the window and app delegate. Storyboards handle all of this for you, so when you try to avoid them, you have a lot of manual setting up that creating non-storyboard projects from the get-go handles for you. Don't do what I did, and try to make your root controller your main view controller, because it will go nuts saying things about how UIApplication isn't key-value compliant for individual properties of your XIB.
As a few others have suggested, your best bet is to clone the views from storyboard into an XIB.
It's not possible to get xib files. Your storyboard is compiled to nib files and packaged into a storyboardc file within your app bundle.
To locate the nib files select your built executable in Finder and right-click 'Show package contents'. Navigate to the en.lproj directory and find the storyboard.storyboardc file. Right-click 'Show package contents' again on the storyboard file and you will find your nibs. They will not be much use to you though because they are compiled binary nibs.
You may not be able to extract the .xibs from the storyboard, but try this. Have your .xib based project open and create the empty .xib files for your views and also have the storyboard project open at the same time. Select all the UI elements in your storyboards scene and simply drag and drop them over to the .xib based project. I have done this the other way around (moving from .xib to storyboard) with no problems.