Bug 9482 - Crash on button click in UIView in UIViewElement
Summary: Crash on button click in UIView in UIViewElement
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.1.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-01-10 22:21 UTC by wks101
Modified: 2013-01-14 09:57 UTC (History)
3 users (show)

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

Demo project (1.33 MB, application/zip)
2013-01-10 22:21 UTC, wks101

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 wks101 2013-01-10 22:21:35 UTC
Created attachment 3196 [details]
Demo project

Clicking a UIBtutton contained in a UIView contained in a UIViewElement results in unrecognized selector sent to instance.

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[__NSMallocBlock__ BridgeSelector]: unrecognized selector sent to instance 0x100970f0
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38

This occurs with both outlet and Action.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2013-01-11 06:45:31 UTC
The HasButtonVC instance is freed by the GC because it's not referenced by anyone.

If you declare hasButtonVC as a class variable in MainVC.cs the crash goes away.
Comment 2 Miguel de Icaza [MSFT] 2013-01-14 09:57:45 UTC
It is a really bad practice to take the View from a UIViewController and put it on a standard UIView that is being managed by another controller.

Not to mention that in this case, it is being added to a UITableViewCell, which is even worse.