Bug 17979 - translationInView should allow null to get the translation in the Window
Summary: translationInView should allow null to get the translation in the Window
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 7.0.6.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: 7.2.1
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2014-02-24 17:28 UTC by Damon Bohls
Modified: 2014-03-20 10:50 UTC (History)
4 users (show)

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


Attachments
Test case (5.69 KB, application/zip)
2014-02-24 17:43 UTC, Adam Kemp
Details


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:
Status:
VERIFIED FIXED

Description Damon Bohls 2014-02-24 17:28:42 UTC
Regarding this code in MonoTouch.UIKit.UIPanGestureRecognizer

[Export("translationInView:"), CompilerGenerated]
public virtual PointF TranslationInView(UIView view)
{
	UIApplication.EnsureUIThread();
	if (view == null)
	{
		throw new ArgumentNullException("view");
	}
        ....


My understanding is that I should be able to call this function with view == null to get the translation in the Window.
Comment 1 Adam Kemp 2014-02-24 17:43:29 UTC
Created attachment 6137 [details]
Test case

Run the attached project and touch anywhere on the view to crash. Then change the gesture code (in AppDelegate.cs) to use the alternative implementation (directly calling "translationInView:" with a null view) to see that it works with null in Apple's code.
Comment 2 Sebastien Pouliot 2014-02-24 20:47:16 UTC
Thanks for the test case! It looks like a non-documented behaviour [1] but other API uses a similar trick, where a nil UIView means UIWindow.

I'll check for the other API in the type, e.g. velocityInView:, and fix this for the next maintenance release.

[1] https://developer.apple.com/library/ios/documentation/uikit/reference/UIPanGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/instm/UIPanGestureRecognizer/translationInView:
Comment 3 Sebastien Pouliot 2014-02-24 21:29:23 UTC
UIPanGestureRecognizer accepts null for UIView in SetTranslation, TranslationInView and VelocityInView methods.

Fixed in master / 7d2e3d361f20147789629c732e6f2b6029b05166

QA: unit tests added in the same revision
Comment 4 Ram Chandra 2014-03-20 10:50:36 UTC
I have checked this issue on following builds:

Mac
Xamarin Studio : 4.2.4 (build 32)
Xamarin.iOS : 7.2.1.20 (Trial Edition)
Build Information
Release ID: 402040032
Git revision: a160c35dac9ab9fd32eeadaa171216316d5a5133
Build date: 2014-03-12 13:55:08-04
Xamarin addins: a779416ceabd54981ce812771a4061c942e8b872

I have checked the signature of "TranslationInView(UIView view)" in "assembly browser" and I observed that now we are able to call this method with "view==null" to get the translation in the Window and it will not throw ArgumentNullException exception.

screencast:  http://www.screencast.com/t/QstFoyy7d

This issue is working fine. Hence, I am closing this issue.