File's Owner is not showing Tab bar controller Outlet? - iphone

I have included Tab Bar Controller in my application.
I have declared Outlet in the App Delegates' .h and .m file.
When I am right clicking on File's Owner, It doesn't show me Outlet.
OR
If I double click on the Tab Bar Controller I could not see the Outlet.
How to connect it...
I have Included the XIB file in an empty app.
I am using Xcode 4.
Any body can tell me how to get APPLICATION DELEGATE icon when clicking on xib file...??

Click on the app delegate icon and not on the file's owner.
Did you set the class for that xib or not. you can check that in the custom class group like in this pic. If not than you should set it with a class name of your choice.

Arpit, Instead of declaring Outlet in ProjectNameAppDelegate.h file that is being shown in side list... declare in .h file with the same name as .xib file... Same problem has been faced my me also... Hope this will help you...

You need to get the the type "'Object'" and drag it to the Below the File's Owner Window.
Set it's Class to your present appln delegate..this is the way you can create app delegate if not present by default near file's owner.

Related

Connection issue of Xib and created outlets

I have two seprate projects and both having viewController classes with same name .
I import one projects file in other with Xib,i changed second class with its xib name and its running fine .
But when i look in xib the objects in xib not showing its refrence outlets which i created in .h class. please help me in this situation .
click the File's owner in which xib you wants to referenced and do select or write the class name for appropriate class
select File's owner
click identity inspector(3rd tab on inspector view)
select or write appropriate class names under custom class.
After this, the reference which you add on .h file will show on it.

How to change label of tab bar item dynamically (IPhone dev)

I'm using XCode 4.1 and I have an already existing IPhone app.
In the "MainWindow.xib", in the Interface builder, there is a Navigation Controller. Inside it, a Tab Bar Item with a title on it. I need to change this title dynamically. However, there seems to be no ".h" file associated with the MainWindow.xib, so I have no idea how to access this object. Any idea?
You don't need a .h file to access items in MainWindow.xib. You can declare IBOutlets in your app delegate for the items you want to access. One of the objects in MainWindow.xib is the app delegate, so you can assign elementos to its IBOutlets.
The main window or the tab bar bontroller was, somehow, related to another controller (associated with a .h and .m file).
So in this controller, I added this code :
UIViewController *uvButton1 = [self.tabBarController.viewControllers objectAtIndex:0];
uvButton1.tabBarItem.title = NSLocalizedString(#"KEY", nil);
and so on for the 2 others (changing the index "0" for "1" and "2");
the NSLocalizedString function goes to a localized file (Localizable.strings) and chooses the right text based on the key. You can also just use a standard string there.

how to link view controller and .xib file to tab bar item in xcode 4

I have a tab bar with 4 items and i want to link the .xib files to each item. The problem is that the NIB File Name shows no items, and if i write the .xib for example, StartView without the .xib i get an error. I get the same error when i link the tab item to the view controller class in the Identity Inspector. This is the error:
'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "StartView" nib but the view outlet was not set.'
I had no problem with this in Xcode 3. As far as i know i don't need outlets in my view controller to be able to link a view to a bar item.
Any ideas on how to fix this?
Thanks.
Each .xib has a main view that must be connected to its files owner. Usually when you change the class name of a .xibs owner, the view outlet will become disconnected. So you'll want to first check that the class name of your .xib is the custom controller you have made. You then have to open the .xib and click on the connections inspector. Then just drag and connect the view outlet (labelled as view in the connections inspector) to your view.
Cheers.
Problem solved, but i didn't like the solution. I created the view controller again and selected to create a .xib file along with the controller and that was it. Then i made the usual references from interface builder and it's working. I didn't like it because the .xib file has the same name as the view controller class. If anyone knows how to create the .xib file and the view controllers separately and get it to work, please inform me, i would really appreciate it.
select create new file, objective c, check the make xib file box and in the name of it, add .xib extension to the end of the name

How to make a "view" Outlet show up in a ViewController nib?

I'm working on my first iPhone app and have been able to get most things done. There's one problem that I've run into a few times and I want to understand the issue better.
In XCode, if I go File->New File->UIViewController subclass and make sure that both UITableViewController subclass and With XIB for user interface are checked, then it creates a MyViewController.h, MyViewController.m, and MyViewController.xib.
When I look at this xib in Interface Builder, you can see that the File Owner has an Outlet called view that is already connected to the UITableView. No problem. This all makes sense and is great.
My issue comes when I've changed the type of my class (or done something else) and some how the "view" Outlet goes away. I get an error saying "view not showing up in file owner outlet".
My question is how do I then reconnect the UITableView as the "view" of the ViewController when the Outlet goes away? The only way I've been able to get it to work is to literally start over with a new xib/viewcontroller.
That "view" outlet should be coming from the parent class (in your case UITableViewController).
What do you mean by change type? If you are changing the name of your class, try using Edit > Refactor with the class name selected in Xcode.
In the "Document" window (cmnd + 0) - control + click on file's owner, a weird looking line thing will show up. drag the mouse over to your view and release. a little drop down will come up from which you can set the view to the File's Owner View outlet.
Typically the "view" outlet would be coming from the parent class (UITableViewController). If it's not showing up, then Interface Builder is not connected to your project than this could happen instead.
My problem was due to an edge case as described here: Interface Builder and Xcode integration not working

How to edit the MainWindow.xib (to change the default view it loads)

Hi I am trying to change the default view MainWindow.xib loads. I am using view based app. I changed the app delegate file, added my new view as a subview to the main window. but in interface builder it still says mainwindow.xib loads from the default view not my newly added view. (BTW I added a new xib file for my new view and that is the one I want to load at startup.)
thanks.
If you want to change from using MyAppViewController.xib to `MyOtherView.xib', you also need to change the class of the view controller in Interface Builder. You can do this by selecting the view controller, going to the Identity tab (the last one) and putting the class name of your new view controller in the "Class" field.
Change the 'Main nib file base name' in the Info.plist of your App too if you have another Main.XIB.