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 17293 [details]
Demonstration project showing the error.
Every time you tap an UIButton it's Layer gets re-referenced, therefore any custom state saved on it is gone.
A good addition i've just found.
When you bind the layerClass native method to your UIButton and assign it to a CALayer subclass, the UIButton's Layer property doesn't get recreated anymore.
public class WeakButtonLayer : CALayer
public class WeakButton : UIButton
public WeakReference<CALayer> WeakLayer;
public static Class GetLayerClass()
return new Class(typeof(WeakButtonLayer));
public WeakButton(CGRect frame) : base(frame)
this.WeakLayer = new WeakReference<CALayer>(this.Layer);
I could not reproduce this using an iPhone SE on 9.3.5 nor on an iPhone 6 Plus on 10.0.
Can you share with us your version information?
The easiest way to get exact version information is to use the
"Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details"
button and copy/paste the version informations (you can use the
"Copy Information" button).
Below is my current installation info:
=== Xamarin Studio Community ===
Version 6.1 (build 5383)
Installation UUID: 4cdc71f8-5b1e-44d7-b378-b8c7087320cf
Mono 4.6.0 (mono-4.6.0-branch/3ed2bba) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 406000182
=== NuGet ===
=== Xamarin.Profiler ===
=== Apple Developer Tools ===
Xcode 8.0 (11239.2)
=== Xamarin.iOS ===
Version: 220.127.116.11 (Xamarin Studio Community)
Build date: 2016-08-30 18:12:06-0400
=== Build Information ===
Release ID: 601005383
Git revision: 37159a7d0c1ed6c9f661210879e9e233ca92e65d
Build date: 2016-08-30 22:07:20-04
Xamarin addins: 00a35f60101b50c8fa28b2b8c0e5b8ade85f7083
Build lane: monodevelop-lion-cycle8
=== Operating System ===
Mac OS X 10.11.6
Darwin El-Capitan.local 15.6.0 Darwin Kernel Version 15.6.0
Thu Jun 23 18:25:34 PDT 2016
=== Enabled user installed addins ===
NuGet Package Management Extensions 0.11.1
When you run the attached project, press the "Click me!" button.
The current (bugged) output for the attached project should be:
2016-09-02 17:36:38.188 ProofLeak[21859:1483917] WeakLayer.Target =
2016-09-02 17:36:38.378 ProofLeak[21859:1483917] WeakLayer.Target =
2016-09-02 17:36:38.690 ProofLeak[21859:1483917] WeakLayer.Target =
2016-09-02 17:36:38.866 ProofLeak[21859:1483917] WeakLayer.Target =
And the expected output for the attached project (upon fix) should be:
2016-09-02 17:37:55.494 ProofLeak[21871:1484949] WeakLayer.Target = <CALayer: 0x7b7f7700>
2016-09-02 17:37:55.643 ProofLeak[21871:1484949] WeakLayer.Target = <CALayer: 0x7b7f7700>
2016-09-02 17:37:55.796 ProofLeak[21871:1484949] WeakLayer.Target = <CALayer: 0x7b7f7700>
2016-09-02 17:37:55.939 ProofLeak[21871:1484949] WeakLayer.Target = <CALayer: 0x7b7f7700>
2016-09-02 17:37:56.091 ProofLeak[21871:1484949] WeakLayer.Target = <CALayer: 0x7b7f7700>
Yup that is the output that I am getting
Could you tell me on which device are you testing this?
I've tested on every single device from iOS Simulator.
Also tested it on my physical device (iPhone 5) with no luck.
I'm Installing a fresh Xamarin copy on another Mac and going to testing it.
I'll keep you informed!
Hi Jairo, did you ever get this tested on a fresh mac?
@Jaro any comments or information regarding the issue?
@Jaro If you are still experiencing this issue please re-open the bug report. Thanks!