Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 15, 2008, 01:51 PM   #1
RossOliver
macrumors regular
 
Join Date: Nov 2006
Setting the view controllerís nib file name in Interface Builder

Hey,

Reading through the apple documentation, I came across this paragraph:

Quote:
If you use Interface Builder, it is recommended that you set up the views for your view controllers in separate nib filesóthat is, you create a nib file for each application view. In this case, you set the Fileís Owner to your view controller subclass and connect the Fileís Owner view outlet to the root view in the nib file. You can then create the view controller programmatically using the initWithNibName:bundle: method or by setting the view controllerís nib file name in Interface Builder. When you set the nib file name, an instance of your view controller class is created and initialized with the contents of the specified nib file.
How exactly do I set the view controller's nib file name in IB? Also, how would I then go on to create an instance of my view controller so it loads the nib and so I can then add it as a sub view etc...

Full document here: http://developer.apple.com/iphone/li...007457-CH5-SW1

Cheers
RossOliver is offline   0 Reply With Quote
Old Jun 15, 2008, 02:10 PM   #2
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
Select the file owner and set its class to your custom class. Post again if this doesn't make sense.
__________________
If they have to tell you every day they are fair you can bet they arent, if they tell you they are balanced then you should know they are not - Don't Hurt me
Eraserhead is offline   0 Reply With Quote
Old Jun 15, 2008, 02:33 PM   #3
RossOliver
Thread Starter
macrumors regular
 
Join Date: Nov 2006
Quote:
Originally Posted by Eraserhead View Post
Select the file owner and set its class to your custom class. Post again if this doesn't make sense.
Ah, I had done that - I thought there was more to it ...

Another question you (or anyone else) may be able to help with. The MainWindow.xib that is provided - should that be left blank and should I create my main view in another nib, say MainView.xib or should I just create the view in MainWindow.xib?

I ask because it doesn't make sense to me how the MainWindow.xib view would be correctly handled - surely it needs a view controller, but I wouldn't be able to make the view controller it's file's owner. Would this mean I would have to load the view using initWithNib? (that method may not be accurate)

Thanks again.
RossOliver is offline   0 Reply With Quote
Old Jun 15, 2008, 02:50 PM   #4
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
You should just stick the main view in the first .xib

With regards to having lots of multiple files there used to be two reasons for having multiple .nib files for everything.

1) Its easier to localise if you are using version control software. But with the new .xib format that is no longer a big issue. I suppose its a slight issue still as the translators don't know what has changed as clearly, but it shouldn't matter too much.

2) There might be slightly worse performance, to put this in perspective on the Mac I have nibs with 20 windows and that part of loading takes around 1/1000th of a second. On the iPhone this may be more of an issue, but you should be OK with having a small number of views in the same nib without issue, you'll have to performance check this yourself .
__________________
If they have to tell you every day they are fair you can bet they arent, if they tell you they are balanced then you should know they are not - Don't Hurt me
Eraserhead is offline   0 Reply With Quote
Old Jun 16, 2008, 01:18 PM   #5
RossOliver
Thread Starter
macrumors regular
 
Join Date: Nov 2006
Quote:
Originally Posted by Eraserhead View Post
You should just stick the main view in the first .xib

With regards to having lots of multiple files there used to be two reasons for having multiple .nib files for everything.

1) Its easier to localise if you are using version control software. But with the new .xib format that is no longer a big issue. I suppose its a slight issue still as the translators don't know what has changed as clearly, but it shouldn't matter too much.

2) There might be slightly worse performance, to put this in perspective on the Mac I have nibs with 20 windows and that part of loading takes around 1/1000th of a second. On the iPhone this may be more of an issue, but you should be OK with having a small number of views in the same nib without issue, you'll have to performance check this yourself .
OK, I think I understand now

Last question (hopefully) - I have an interface consisting of a UIView, UITableView and a UIButton.

The file's owner is set to a UIViewController which has an IBOutlet for the UIButton and UIView. It also has an IBAction method to handle the UIButton press.

I have a UITableViewController for the UITableView datasource/delegate methods.

What I want to do is refresh the UITableView when the UIButton is pressed, but what I can't work out is how to let the UIViewController know about the UITableViewController so it can refresh the UITableView. Do I just add the UITableView as an IBOutlet in the UIViewController and hook it up in IB?

Cheers
RossOliver is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Pashua gui tool interface elements anything similar in xcode interface builder wild4life2013 Mac Programming 1 Aug 10, 2013 08:13 PM
OpenGL ES without interface builder? blueshogun96 iPhone/iPad Programming 1 Feb 10, 2013 01:04 PM
About push view controller into a navigation controller stack. cthesky iPhone/iPad Programming 5 Nov 9, 2012 08:36 AM
Segue from Normal View controller to navigation controller daproject85 iPhone/iPad Programming 0 Sep 29, 2012 03:26 PM
push to a specific view controller regardless of which controller is active johnmerlino iPhone/iPad Programming 2 Jun 19, 2012 02:24 PM

Forum Jump

All times are GMT -5. The time now is 12:30 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC