Bug 10139 - LoadNib() Bug - Switching from Storyboards to .xib
Summary: LoadNib() Bug - Switching from Storyboards to .xib
Status: RESOLVED DUPLICATE of bug 10136
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 6.1.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-02-07 19:57 UTC by Andrew Way
Modified: 2013-02-08 06:08 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Andrew Way 2013-02-07 19:57:06 UTC
original reporter: isaac.eckert@fanucrobotics.com

I discovered this bug while switching over from Storyboards to *.XIB files.
The method NSBundle.LoadNib(string, NSObject, NSDictionary) incorrectly throws an exception when passing NULL as the value of the second parameter (file owner).  This constraint prevents the method from being used to load a UIView object from a XIB file without a UIViewController or other owner type.
Fortunately, I have sufficient access to work around the wrapper:
Selector selector = new Selector("loadNibNamed:owner:options:");
      IntPtr stringPtr = NSString.CreateNative("MyUIViewXib");
      NSArray result = (NSArray)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSendSuper_IntPtr_IntPtr_IntPtr(NSBundle.MainBundle.SuperHandle, selector.Handle, stringPtr, IntPtr.Zero, IntPtr.Zero));
You may recognize the code since it is taken directly from within the wrapper method.  The only real different is that I am passing IntPtr.Zero for the owner instead.  The resulting NSArray contains an instance of my custom UIView as the first entry.
      UIView myView = (UIView)Runtime.GetNSObject(result.ValueAt(0));
LoadNib() should be changed to allow null parameters.  Until then I will have to write code like above and I don’t know what the impact on other developers will be.  Already, there is a lot of misinformation on the internet about how to load UIViews from XIB files.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2013-02-08 06:08:57 UTC

*** This bug has been marked as a duplicate of bug 10136 ***