UINavigationController on the flipside view - iphone

I am having a problem with creating a navigation controller after on the other side of the application :) ... I mean after clicking this small info button and flipping on the other side ...
I'm getting this error:Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "InfoController" nib but the view outlet was not set.'
And I know that the problem is somewhere in connecting the view outlet to the the view ...
Screenshot from my IB is here:
I will appreciate any help as this is the last piece of my app I need to finish ...

UIViewController has a ivar called view. If it is not connected in IB (or set in code), you'll get this message. In IB, click on "File's Owner", then click on the "Connections" tab in the Inspector. Under "Outlets" what is the "view" parameter connected to? It needs to be connected to the view you intend to control from your InfoController.
That being said, there is some inconsistency in what you are showing in your screenshot. Normally, you won't have a UINavigationController be part of your UIViewController xib. Instead, it should be in your MainWindow.xib. You can try to drag a connection from your File's Owner to the view inside of your navigation controller, but I don't think that will work. You'll have to move the navigation controller to your MainWindow.xib and then set it's view to be of type InfoController using xib InfoController.
If this is unclear, create a new project using the "Navigation-based Application" template in Xcode. Then open the MainWindow.xib file in IB. You'll see in there how the navigation controller should be set up.
You'll get more visibility on this question if you add 'iphone' as a tag, by the way.

Related

UIWebView error on Tab Bar Controller

I really need help on creating a UIWebView on a Tab Bar Controller. But I Bumped into a road block.
Basically I started out with the Tab Bar Application Template, then;
Removed the First and Second Controller XIB files on the resource folder (since it's not really needed
In Interface Builder, I removed default contents in the First and Second View Controller and added a View first, then a Web View after that on both the View Controller
After that, I started coding on both on the First and Second View Controller headers with just this code:
#interface FirstViewController : UIViewController { IBOutlet UIWebView *twitter; }
(also for the Second View Controller's header)
Then I linked the Outlets to the UIWebView and linked both Tab Bar Item to their Class View Controller (First Tab Bar Item linked to the FirstViewController class, then for the second one as well)
Later in both the View Controller's .m files, I added
- (void)awakeFromNib
{
[twitter loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"twitter.com"]]];
}
(and for the other one)
Now when I compiled the application, it gave me:
'First View Controller (First)' has both its 'View' and 'NIB Name' properties set. This configuration is not supported.
I looked through every youtube video about this topic, but none of their comments even mentioned anything about this kind of error, I hope someone can explain how to get through this error, thanks
In Interface Builder you can either define a view in your MainWindow.xib directly inside the TabBarController, or you can tell Interface Builder that those views are loaded from separate XIB files.
It sounds to me like you are defining the views directly inside your main XIB, so in that case you need to select the view controllers that are in the TabBarController, hit Apple-1 to open the attributes pane for the controller, and clear the "NIB name" field which is probably still set to "FirstViewController". Do the same for any other view controllers you have in your TabBarController.

Could someone post instructions for how to create a modallly presented tab bar controller?

I'm just trying to make the most basic tab bar controller that gets presented modally. I want to use nibs, as opposed to doing it all programatically, but I really don't understand Interface Builder:
Why can't I drag a tab bar controller into my veiw?
Why does IB create another "window" when I drag a TBC to the document window?
Why are there 2 view thingys in the same nib?
Why do I get this message (crash) when I try to present the modal view: "nib but the view outlet was not set" ?
How do you remember which little connections you need to make in IB, other than the obvious ones you reference in the code?
Is there an IB tutorial out there that goes beyond just the most basic pre-made application templates and actually explains what's going on?
Why can't I drag a tab bar controller into my view?
Because only other views can be dragged onto views. A view controller is not a view.
Why does IB create another "window" when I drag a TBC to the document window?
Because every view controller has its own main view. If you double click a view controller in IB, its view opens.
If you really want to create all controllers from a NIB file, do it like this:
Create a fresh empty XIB file called "TabBarController.xib". It contains nothing but the entries for File's Owner and First Responder.
Drag a UITabBarController into this XIB. Ignore the view that gets opened (you can close it).
Configure the tab bar controller according to your needs, especially by dragging as many UIViewController objects (or UIViewController subclasses) onto the tab bar controller as you have tabs. If these child view controllers should be instances of your custom view controller subclasses, make sure to set their classes accordingly in the Inspector.
For each child controller of the tab bar, create another XIB file in Xcode, this time using the View XIB preset. Let's call these "ChildController1.xib", ... Open all of them in IB and set their File's Owner class to the class of the corresponding child controller (i.e., UIViewController or a subclass). Then connect the views in these XIB to the view outlet of File's Owner. Configure these views as you need them (by adding the actual UI elements of the child views and possibly connecting other outlets if necessary).
Close the child XIBs and return to TabBarController.xib. For each child controller, open the Attributes Inspector and set its NIB Name attribute to "ChildController1", "ChildController2", ... Then close the XIB.
In your code:
NSArray *nibFile = [[NSBundle mainBundle] loadNibNamed:#"TabBarController" owner:self options:nil];
UITabBarController *tabBarController = [nibFile objectAtIndex:0];
[self presentModalViewController:tabBarController animated:YES];
I broke down and just configured the TabBarController without using Interface Builder. The more I'm getting into iPhone development, the more I'm realizing that IB is bad, and to not use it except for the rare components with absolute layouts. In this case, all you would gain by using it would be the icons and titles on each tab. IB doesn't really provide any earth-shattering visualization on that.
I really wish nibs rendered down into some readable text format, so you could always drop to the code to understand what was going on, but that's not the case, so I'll gladly add 6 lines of code to make my program not crash

not able to connect view controoller to appdelegate in main window nib

i have added an view controler to interface builder and trying to add connection but is not allowing to connect, buti have created ib outlet for that and is visible in IB...
i forgot to give controller name in IB ui view controller

How do I set a view programmatically for my tabBarController?

I have a tabBarController xib. I've set the first item's class to a view controller I made (.h and .m files, no .xib). When I try to push the tabBarController, I get a warning saying the tabBarController "view outlet was not set".
I'm not sure how to set the view outlet, since I am loading from another view. I'm expecting the default grey view with detailed edges will load from my ViewController.h file because I set the class there, but instead I'm crashing with that error.
Suggestions?
Normally, you would add view controllers to the tab bar controller in the xib. They need to have a view linked up, which you can also do in IB.
If you want to do that programmatically, you should, after loading the xib, but before showing the vc, take the elements of
NSArray *vcs = [tbCtrl viewControllers];
walk through them, and set their view property to a view. When pushed, the tab bar controller will know which view to load: namely the view of the first tab. These things are really much easier to handle in IB.

Iphone sdk tabbar View outlet was not set

I'm about at the end of my rope with this freaking project!!!!!!!
I have a UIViewController class that is linked to a nib that has a tabbar controller with 2 tabs. Both tabs load nib files. When I compile I get an error:
-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MainViewController" nib but the view outlet was not set.
What's going on here? MainViewController views are being populated by nib files (and those files views are linked correctly).MainViewController's Files's Owner has a parameter "view" but shouldnt that be ignored since Im loading both views from a nib? ANY help would be appreciated!
I had the same error (loaded the "xViewController" nib but the view outlet was not set.) in the debugger.
In Interface Builder, I opened the xViewController.xib, right-clicked the View icon, dragged from the circle beside New Referencing Outlet over to the File's Owner icon, then, when the small gray menu appeared, I clicked view. (Then save, rebuild, run, etc...)
I'm not clear on what's going on, but that fixed it.
From what I understand, if anybody wants to follow-up, the View's outlet (which is named "view") was not set, and by dragging the New Referencing Outlet over to the File's Owner icon, I set the View's outlet. Great.
Issue #1 - nib but the view outlet was not set.
1. My MainMenu.xib that had the tabbarcontroller, it's File's owner MUST be connected to some sort of view. So putting in a view object and linking it is fine. I was getting annoyed because it kept showing that file and not the tabbar. #2 solves that problem
Issue #2 - no tabbar being shown
2. Create an IBOutlet UITabBarController and link that to the files owner. And then in the viewdidload method do this self.view = tbController.view; and now your tabbar is being shown not that blank view file you linked to!
You need to add the view from each external nib to the main xib and then connect the view outlet to the correct view. For example, if you have the tab bar in MainMenu.xib and an external xib named ViewOne.xib then open both of them, drag Custom View (or whatever it's called) from the ViewOne.xib window to the MainMenu.xib window. Then connect the view outlet of the tab for that view to Custom View. You should probably rename Custom View once you copy it to MainMenu.xib so that can tell it apart from the other views you will have to add to MainMenu.xib.