Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 1535 [details]
The attachment contains a comparable project with the problem.
I have a problem with a UITextField delegate. The attachment contains a small project with the problem.
What I want to do is when you click the done button a UIAlertView will appear you have to fill in a barcode number and when you click the done button de UIAlertView must disappear.
When I click the done button monotouch is giving me an error. I can't find the solution for this problem. Can you help me?
We have a similar piece of code in Objective-C and it works.
Are you using MonoTouch 5.0 (like the bug report says) or something more recent ?
Please add all product versions so we can use the same settings. You can find them in MonoDevelop (menu), About MonoDevelop (item), Version Info (tab) and copy-paste the data up to the assemblies versions.
Also if you could attach your objc sample it could help. Thanks
Installation UUID: 78f51f43-1acc-4c9e-af1e-c04e6c342d4f
Mono 2.10.9 (tarball Wed Feb 29 17:12:24 EST 2012)
Mono for Android not installed
Apple Developer Tools:
Xcode 4.3.1 (1176)
Monotouch: 5.2.9 (Evaluation)
Release ID: 20808001
Git revision: 68894cb4683cf4be662f84d8e786e75b47671d10
Build date: 2012-02-28 22:59:41+0000
Xamarin addins: 0aa7cf395748cfd1ff3d58df94b5cf38ed047c3e
Mac OS X 10.7.3
Darwin MacBook-Pro-van-Jonah-Hulselmans.local 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64
I will attach an Objective-C example.
Your issue is this line:
UITextField input = barcodeEntry.GetTextField (0);
once the `openUIAlertView` method returns nothing (in the managed side) refers
to `input` so the GC can collect it (whenever it wants).
However you changed this `UITextField` instance (native side) by setting a
delegate to it. This means ObjectiveC (native side) will want to call back into
the delegate (and back into managed code) but it was collected -> crash.
The solution is to keep a reference to the instance so it won't be gargabe
collected (and will still exists/be valid when the native code call backs into
it). You can do this by promoting the local variable `input` as a type field.