Re: Converting a Storyboard into separate NIBs.
Re: Converting a Storyboard into separate NIBs.
- Subject: Re: Converting a Storyboard into separate NIBs.
- From: Alex Zavatone <email@hidden>
- Date: Mon, 19 Jun 2017 16:29:54 -0500
> On Jun 19, 2017, at 3:25 PM, Charles Srstka <email@hidden> wrote:
>
>> On Jun 19, 2017, at 2:51 PM, Alex Zavatone <email@hidden
>> <mailto:email@hidden>> wrote:
>>
>> What is EXCELLENT is when you take the storyboard and remove all the top
>> level views. Then, create individual XIBs for each scene. The
>> viewController.h specifies that “if a view can not be found, an .xib with
>> the same name of the class file will be looked for and will be loaded if
>> found.” I’ve seen this text in the viewController.h since 2009, if I recall
>> correctly, so it’s not due to change any time soon.
>
> Keep in mind that according to the documentation, this is only true of macOS
> 10.10 and higher. So if you are targeting 10.9 or below, you cannot do this
> (although it’s fairly trivial to write one’s own general NSViewController
> subclass that does this, as I did for many years before the built-in
> functionality was introduced).
>
> Charles
>
Noooooooo. I started doing this back in iOS 5.
I just fired up Xcode 4.2, build 4C199 and took this screenshot:
http://i.imgur.com/Yheac01.png
From line 153 of UIViewController.h:
As a convenience, the default init method will do this for you,
and specify nil for both of this methods arguments.) In the specified NIB,
the File's Owner proxy should
have its class set to your view controller subclass, with the view outlet
connected to the main view. If you
invoke this method with a nil nib name, then this class' -loadView method
will attempt to load a NIB whose
name is the same as your view controller's class.
The pearl is here:
If you
invoke this method with a nil nib name, then this class' -loadView method
will attempt to load a NIB whose
name is the same as your view controller's class.
The thing is that we don’t call loadView, but it is called without a nib name
when the OS calls it. This is done and has been done automatically for over a
decade, by the OS, if I’m not mistaken.
I’m sure we all have work to do, but it’s easy enough for me to open apps I
created from 2014 and before where we used this in shipping products to prevent
storyboard merge issues.
And here we go. 2014. Xcode 5.0.2
View Controller doing nothing special on its init methods + xib right below it.
http://i.imgur.com/Btgc4w5.png
Storyboard serving as a skeleton with the top level view removed from a scene
http://i.imgur.com/Zc2AtJC.png
I just unearthed xcode_3.2.4_and_ios_sdk_4.1.dmg from 2010. After I get a
spare VM set up, I’ll see what the viewController.h comments say.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden