Bug 9699 - When subclassing NSViewController cannot set View.Frame unless new view is instantiated manually
Summary: When subclassing NSViewController cannot set View.Frame unless new view is in...
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 1.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2013-01-21 20:36 UTC by Mike Bluestein
Modified: 2013-05-15 00:05 UTC (History)
2 users (show)

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

test case (21.20 KB, application/zip)
2013-01-21 20:36 UTC, Mike Bluestein

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 Mike Bluestein 2013-01-21 20:36:13 UTC
Created attachment 3254 [details]
test case

Create a new Xamarin.Mac application and add a new class that subclasses NSViewController. Then add code to set the View's Frame in the constructor of the new class, for example:

	public class FooController : MonoMac.AppKit.NSViewController
		public FooController () : base ()
			// will crash if you don't have following line:
			// View = new NSView ();
			View.Frame = new System.Drawing.RectangleF (0, 0, 100, 100);	

Without the line of code to instantiate the View, the application crashes with the following error:

[NSViewController loadView] loaded the "(null)" nib but no view was set
Comment 1 Miguel de Icaza [MSFT] 2013-05-15 00:05:39 UTC

I suspect this is the same scenario that happens on iOS, the View is not valid until  viewDidLoad is invoked.