Bug 3711 - UIImagePickerController's delegates
Summary: UIImagePickerController's delegates
Status: CONFIRMED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: 5.2
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-03-01 22:42 UTC by Miguel de Icaza [MSFT]
Modified: 2016-02-11 15:06 UTC (History)
4 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Miguel de Icaza [MSFT] 2012-03-01 22:42:05 UTC
The automatically generated delegates in UIImagePickerController pose a problem.

The class actually detects from Objective-C which selectors have been implemented, in our case, it probes for imagePickerController:didFinishPickingMediaWithInfo: and if it is there, it calls that method instead of calling ImagePickerController:didFinishPickingImage:editingInfo:

The problem that we have is that our approach at implementing all methods in the delegate class leads to methods not being invoked.

The fix is to use Runtime.ConnectMethod for the methods that are actually used, instead.   We could ease this by only landing some of these changes on some classes for now.
Comment 1 Miguel de Icaza [MSFT] 2012-03-01 22:42:54 UTC
Example that fails:

var picker = new UIImagePickerController ();
picker.FinishedPickingImage += delegate {
   // Never called 
};

foo.PresentModalViewController (picker)
Comment 2 Sebastien Pouliot 2012-03-02 09:07:12 UTC
It won't work in every case (not many of them I think) but could we make our own, default, implementation of "imagePickerController:didFinishPickingMediaWithInfo:" call "ImagePickerController:didFinishPickingImage:editingInfo:" ?
Comment 3 Adam Kemp 2015-09-12 17:25:22 UTC
I just ran into this trying to help someone on the forums (https://forums.xamarin.com/discussion/comment/151759#Comment_151759), and it's kind of embarrassing how old this bug report is with no solution. Has Xamarin given up hope on this, or did it just slip through the cracks?
Comment 4 Rolf Bjarne Kvinge [MSFT] 2016-02-11 15:06:08 UTC
We can fix this by overriding RespondsToSelector in the UIImagePickerControllerDelegate class and return 'false' if there are no event handlers attached for a particular method.

This is how we solved the same problem with ABPeoplePickerNavigationController

Note You need to log in before you can comment on or make changes to this bug.