Bug 29190 - EnablesReturnKeyAutomatically crashes iOS7
Summary: EnablesReturnKeyAutomatically crashes iOS7
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-04-17 09:28 UTC by Justyn
Modified: 2015-04-17 10:00 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 Justyn 2015-04-17 09:28:11 UTC
I've recently had a crash report come through on iOS 7.0.4

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UISearchBar setEnablesReturnKeyAutomatically:]: unrecognized selector sent to instance 0x1509be3f0'

I've identified the code as a call to EnablesReturnKeyAutomatically on a UISearchBar.

This method seems to work fine on iOS 7.1.2+ and I don't see the exception.

I don't have a device with 7.0.4 installed so am unable to test this.

It appears as if the EnablesReturnKeyAutomatically is a convenience function on UISearchBar for toggling the private UITextField setEnablesReturnKeyAutomatically.

I believe that Xamarin must be doing some kind of loop through subviews to access the UITextFiled of the UISearchBar in order to set the property but in iOS 7.0.4 it must not exist or the logic is failing to locate the UITextField.

Could someone please verify if this is the case.

Many thanks,
Comment 1 Sebastien Pouliot 2015-04-17 09:53:32 UTC
> I believe that Xamarin must be doing some kind of loop through subviews to

No, Xamarin.iOS does no such thing. It would be very processing heavy and could too easily break in future version of iOS.

What's happening is that `UISearchBar` started conforming to the `UITextInputTraits` protocol as of iOS 7.1 (it did not before).

It means some API call, e.g.
* EnablesReturnKeyAutomatically;
* KeyboardAppearance;
* ReturnKeyType;
* SecureTextEntry

are _only_ available `UISearchBar` from iOS 7.1 onward.

It's sadly a bit hard to track because both `UISearchBar` (type) and `UITextInputTraits` (protocol) existed in previous iOS release . IOW the metadata about the availability is accurate on each, individually, but not for the (new) relationship between them.
Comment 2 Justyn 2015-04-17 10:00:34 UTC
Thank you for the quick response. That makes perfect sense. You're right that it's hard to track.

I wonder if there's a way that this could be noted within the documentation, like here:


to mention that the method is only supported since iOS 7.1