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

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

Related

Can I bind xib file to view controller via IBOutlet?

I have a ViewController, and I want to dynamically load different UIView based on UISegmentedControl.I designed 3 UIViews in xib file. And I have set their File's Owner's Custtom class to my view controller name in Identify Inspector.After I connect my xib to view controller code via IBOutlet, I add the connected view via "addSubview(view)" method in viewDidLoad method. But When I run it, the compiler tells me that the connected view is null.
Instead of making three different xib files. Make one xib file with all three views in it, plus a fourth "default" view. Each view should be connected to a different IBOutlet in your class.
Then in your viewDidLoad figure out which view you want to display and addSubview it to your default view.

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

How do I create an outlet for additional views?

I'm struggling with the basics on how to build views in Monotouch and how to tie them to C# code.
I know how to create an outlet for an UIViews that are on the Main window. But how can I create an oulet for an UIView that is located on a different view?
The main view has an AppDelegate class I can bind the outlets to. But there's nothing comparable on additional views, even though I chose to create an "Iphone view with Controller".
When you create an "iPhone view with controller", you can open the view controller xib and place your outlets in the UIViewController. So, if you call the new view controller MyViewContoller, you create the outlets on the MyViewController class in interface builder.
MyViewController will be the "File's Owner" in the Interface Builder project window.
Then, you can set up button handlers, etc by overriding MyViewController's ViewDidLoad method.

UINavigationController on the flipside view

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.

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.