On Mar 2, 2011, at 3:54 AM, Andreas Grosam wrote:
> I have a very basic custom UIViewController with its own associated nib file.
> This view controller is the "root view controller" of a Navigation Controller
> which is itself embedded within a Split View Controller which is defined in
> another nib - say the main.nib.
>
> Within IB this root view controller has its "Nib Name" property specified,
> which means that this view controller is defined in an extern nib file.
>
> This scenario is the standard way for defining nibs and view controllers when
> using a Navigation Controller.
> To illustrate an example for the main.nib:
>
> File's Owner
> First Responder
> Window
> App Delegate
> Split View Controller
> Navigation Controller
> Navigation Bar
> Root View Controller -> Nib Name = "MyRootViewController.nib"
> Detail View Controller
>
>
> My root view controller also defines some properly specified outlets - for
> instance a view which is embedded within the same nib file and referenced via
> an outlet from the class.
>
> During -awakeFromNib for the root view controller, none of these kind of
> outlets are connected. This is quite confusing, since the documentation
> explicitly says otherwise.
>
What's going on is that awakeFromNib is called when the nib containing the
object is instantiated. In this case, it is the main nib (which is where the
root view controller "lives").
However, a view controller's nib ("MyRootViewControler.nib") isn't loaded until
it is actually needed, at which point the view controller gets "viewLoaded"
message, and so, until that time, any connections between the view controller
and things loaded from MyRootViewController.nib will be nil.
> During -awakeFromNib for the root view controller, none of these kind of
> outlets are connected. This is quite confusing, since the documentation
> explicitly says otherwise.
>
Not exactly - when awakeFromNib is called, all the connections within that nib
are connected. So if root view controller had an "appDelegate" outlet that was
connected to the App delegate, that would be set when awakeFromNib was called.
The "Nib Name = MyRootViewController.nib" is only an outlet in the sense that
the view controller's nibName ivar will be set to "MyRootViewController.nib"
(which it will be during awakeFromNib).
The whole purpose of having separate nibs is to avoid recursively loading
everything all at once - if that view is never displayed (say, on a tab bar
controller tab that the user never selects), its nib will never be loaded.
Glenn Andreas [email protected]
The most merciful thing in the world ... is the inability of the human mind to
correlate all its contents - HPL
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]