Bug 30503 - LoadView example is wrong according to Apple documentation
Summary: LoadView example is wrong according to Apple documentation
Status: RESOLVED FIXED
Alias: None
Product: Documentation
Classification: Xamarin
Component: MonoTouch ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: CraigD
URL:
Depends on:
Blocks:
 
Reported: 2015-05-27 12:28 UTC by Adam Kemp
Modified: 2015-05-27 12:54 UTC (History)
1 user (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Adam Kemp 2015-05-27 12:28:29 UTC
This document has a bad example:

http://developer.xamarin.com/guides/ios/application_fundamentals/ios_code_only/#Loading_a_View

Specifically this code"

        public override void LoadView()
        {
            base.LoadView();
            view = new CircleView();
            View = view;
        }

Apple's documentation for loadView (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/#//apple_ref/occ/instm/UIViewController/loadView) specifically says you should not call the base implementation:

> Your custom implementation of this method should not call super.

The correct code should just be this:

        public override void LoadView()
        {
            view = new CircleView();
            View = view;
        }
Comment 1 CraigD 2015-05-27 12:54:39 UTC
Thanks for pointing that out!