Bug 2766 - UIBarButtonItem.CustomView cannot be set to null.
Summary: UIBarButtonItem.CustomView cannot be set to null.
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-01-06 19:46 UTC by JohanO
Modified: 2012-01-10 10:26 UTC (History)
2 users (show)

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:

Description JohanO 2012-01-06 19:46:04 UTC
I have some code that changes the custom view of a UIBarButtonItem. The problem is I want to set it back to null.... Observe the following code.

var act = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
button.CustomView = act;

... Do something in a thead ...

// Presumably the button will return to it's original state...
button.CustomView = null; // Raises ArgumentNullException
Comment 1 JohanO 2012-01-06 19:54:32 UTC
Hi, in the interim I have added the following code where the "button.CustomView = null" used to be and it seems to work. Let me know when the bug is fixed so I can remove the ugliness...


					Messaging.void_objc_msgSend_IntPtr(button.Handle, new Selector("setCustomView:").Handle, IntPtr.Zero);
					Messaging.void_objc_msgSendSuper_IntPtr(button.SuperHandle, new Selector("setCustomView:").Handle, IntPtr.Zero);
Comment 2 Sebastien Pouliot 2012-01-10 10:26:45 UTC
You're right, this property should be nullable. This will be part of the next MonoTouch 5.0.x (5.0.6) and 5.1.x releases. 

Thanks for the bug report.