Bug 19098 - CanBecomeFirstResponder is called on a simulator but not on a device (iOS 7.0)
Summary: CanBecomeFirstResponder is called on a simulator but not on a device (iOS 7.0)
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-04-16 18:59 UTC by Zhenya
Modified: 2016-05-24 21:30 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 Zhenya 2014-04-16 18:59:22 UTC
I'm trying to display a UIMenuController for my custom UIView. So I'm doing the following in the UIView constructor:
_tapRecognizer = new UILongPressGestureRecognizer(() => {
	UIMenuController menuController = UIMenuController.SharedMenuController;
	menuController.SetTargetRect(_label.Frame, this);
	menuController.ArrowDirection = UIMenuControllerArrowDirection.Default;
	menuController.SetMenuVisible(true, true);

	_menuController = menuController;

AddGestureRecognizer (_tapRecognizer);

I also have:
public override bool CanBecomeFirstResponder {
	get {
		return true;

Plus I override CanPerform as well:
public override bool CanPerform (Selector action, NSObject withSender)
	switch (action.Name) {
	case "copy:":
	case "paste:":
		return true;
	return base.CanPerform (action, withSender);

However, this only works in a simulator, but not on a real device. I can see that CanBecomeFirstResponder is called on simulator but not on a device. So I assume that's the reason why UIMenuController doesn't appear.
Comment 1 Sebastien Pouliot 2014-04-16 20:43:43 UTC
Could you please attach a self-contained test case so we can be sure we'll check the exact same thing ?

Also please include all the version information, including all software* and also the iOS versions that you used (both the iOS devices/type and the simulator).

* 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).
Comment 2 Zhenya 2014-04-16 22:05:07 UTC
Turns out it works in Release builds, but not in Debug. Maybe the debug build is stripped of the implementation of CanBecomeFirstResponder for some reason? Anyway, this kind of solves this for me.

iOS simulator is iPad 7.0. iOS device is iPad mini 1st gen iOS 7.1. About Xamarin Studio: 4.2.3 (build 60). I believe I have the latest everything from the stable channel.

Sorry, don't have a time to write the test case. Not now at least. Maybe later. Please try to reproduce using the info I provided and I will try to help if it doesn't happen for you.
Comment 3 Zhenya 2014-04-16 22:07:24 UTC
More info:

=== Xamarin Studio ===

Version 4.2.3 (build 60)
Installation UUID: a392b796-a8d8-4070-b1ed-534e25822488
	Mono 3.2.6 ((no/9b58377)
	GTK+ 2.24.23 theme: Raleigh
	GTK# (
	Package version: 302060000

=== Apple Developer Tools ===

Xcode 5.0 (3332.25)
Build 5A1413

=== Xamarin.iOS ===

Version: (Indie Edition)
Hash: 58c3efa
Build date: 2014-10-03 18:02:26-0400

=== Xamarin.Android ===

Version: 4.12.1 (Indie Edition)
Android SDK: /Users//Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Xamarin.Mac ===

Xamarin.Mac: 1.6.27

=== Build Information ===

Release ID: 402030060
Git revision: 30c4afc300c2a39ec5300851357ce02e49dd217e
Build date: 2014-03-05 22:09:33+0000
Xamarin addins: f8a9589b57c2bfab2ccd73c880e7ad81e3ecf044

=== Operating System ===

Mac OS X 10.9.2
Darwin Evgenys-MacBook.local 13.1.0 Darwin Kernel Version 13.1.0
    Thu Jan 16 19:40:37 PST 2014
    root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64
Comment 4 Sebastien Pouliot 2016-05-24 21:30:20 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and re-open the bug report. Thanks!