Bug 43987 - Cannot connect controls to outlets in view controller baseclass.
Summary: Cannot connect controls to outlets in view controller baseclass.
Status: RESOLVED NORESPONSE
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS Designer ()
Version: unspecified
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-09-04 07:32 UTC by Tom Pratt
Modified: 2017-08-22 06:19 UTC (History)
5 users (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 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 NORESPONSE

Description Tom Pratt 2016-09-04 07:32:10 UTC
In the scenario where you have inheritance of view controllers, say a BaseController and a SubController, and the BaseController exists just to share code between subclasses such as SubController. 

Then in XCode you can drag a label onto the BaseController in interface builder and create an outlet in its code behind file.

Then if you drag a label onto SubController and connect to the outlet in the BaseController, xcode allows you to make this connection. And when SubController is instantiated the label property in BaseController is populated allowing you to control it from the BaseController class. If you create an outlet for the label in SubController of the same name, then it is the one which is populated when the viewcontroller is instantiated, the property in the base class remains null.



The problem in the Xamarin Designer is that if you setup your viewcontroller inheritance and base class outlets as above, ready to make the final connection from SubController control to BaseController outlet. Then giving the label the matching Name on the SubController (using the xamarin designer method for creating outlets) then this will create a new outlet in SubController rather than recognising that the outlet already exists in the BaseController.

It would be nice if when the outlet already exists in a base class, then giving a control a name simply adds the necessary <outlet> tag to the .storyboard file without adding new outlet properties to the .designer.cs file of the subclass.



If you setup a storyboard with this method in xcode and then open it in the Xamarin Designer then it will add all of the subclass outlets leading to null reference crashes from the base classes. So I can only ever open/edit such storyboard files in xcode.

My experience is with storyboards, not sure if its the same for .xib files.
Comment 1 Prashant [MSFT] 2017-07-17 05:57:09 UTC
Thank you for taking the time to submit the bug. While we investigate this issue further, please attach a reproduction to the bug by starting with a clean Xamarin.iOS project and adding just the code necessary to demonstrate the issue
Comment 2 Prashant [MSFT] 2017-08-17 07:03:49 UTC
Because we have not received a reply to our request for more information, we are marking this issue as RESOLVED→NORESPONSE. If you are still encountering this issue on the latest Visual Studio 2017 Preview version 15.3, please don’t hesitate to reopen the ticket with the requested information. 

Thanks!
Comment 3 Prashant [MSFT] 2017-08-22 06:19:08 UTC
Because we have not received a reply to our request for more information, we are marking this issue as RESOLVED→NORESPONSE. If you are still encountering this issue on the latest Visual Studio 2017 Preview version 15.3, please don’t hesitate to reopen the ticket with the requested information. 

Thanks!