I'm digging in PlainNote app source code. I notice that there is no instance of rootviewcontroller in appdelegate file. There is only navigationController added to window, but somehow the rootViewController is loaded also.
How this is achieved ?
Check in the MainWindow.xib. That's actually pretty standard way - the XCode Application templates do it too.
Related
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
I know it's a very common error .. I'm using storyboard and I'm getting this error, here's my AppDelegate.m screenshot
keep in mind that I'm beginner and the reason of that maybe so stupid :)
Thanks in advance!
(it's not a bug but I'm just getting a black screen on the simulator)
Use:
window.rootViewController = viewController;
instead of:
[window addSubview:viewController.view];
If I remember correctly, you don't create a UIWindow yourself when you use storyboard. When using storyboard, the main UIWindow is created for you. Since you created your own UIWindow, it's just overlapping and covering up the existing UIWindow. Set the rootViewController in .storyboard by pointing that arrow to it.
By the way, did you create a single view application or an empty application?
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.
created a singleview application with storyboard.
Added three viewcontrollers apart from the one view present by default,Now how to refer to this ViewController programmatically from the AppDelegate did finishlaunchingoptions function? I've created 3 view controller classes and what are the changes i should do in appdelegate
Well it seems as if a tutorial would make sense so you could learn how storyboard based development in iOS 5 works.
A great one i found is this one written by Ray Wenderlich.
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.