Bug 29720 - Setting of e.TargetContentOffset in UIScrollView.WillEndDragging event handler is not honored by iOS.
Summary: Setting of e.TargetContentOffset in UIScrollView.WillEndDragging event handle...
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: XI 8.10
Hardware: PC Mac OS
: --- normal
Target Milestone: 8.10.1 (C5SR1)
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
: 14682 29718 29768 29779 ()
Depends on:
Blocks:
 
Reported: 2015-05-04 16:36 UTC by Jon Goldberger [MSFT]
Modified: 2015-05-08 01:28 UTC (History)
9 users (show)

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


Attachments
Test Project (226.21 KB, application/zip)
2015-05-04 16:36 UTC, Jon Goldberger [MSFT]
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 Jon Goldberger [MSFT] 2015-05-04 16:36:15 UTC
Created attachment 11056 [details]
Test Project

## Description

When trying to set the targetContentOffset property to adjust where the view will end its scrolling after dragging is ended, the property appears to be set when viewing it in the watch window but iOS does not seem to honor the setting. I noted the same thing occurred when using the standard delegate method instead of the event handler. 

#Steps to reproduce

1. Open the attached test project, restore packages, and launch to an iOS simulator. Tested with iPhone 5s iOS 8.3 sim.

2. Scroll the view such that it continues scrolling a bit after removing your finger from the screen. You may need to do this a few times before seeing the issue.

Expected result: The blue boxes will always line up so that one is centered and the other two are fully on screen.

Actual result: sometimes the blue boxes are not aligned properly and the middle one will be off-center. 

Screencast: http://screencast.com/t/TFUCGOy1k
Above shows incorrect behavior followed by correct behavior.

## Notes
To verify correct behavior, change "false" to "true" for the compiler #if statement on line 34 of CardScroller.cs. This will use the Delegate method created by the user who reported this issue. Tis delegate method does not use the "standard" delegate method signature one would get if using auto-complete after typing "override ". The same behavior is noted when using the "standard" delegate method signature, but not when using the signature in the test project, which is:

>[Export("scrollViewWillEndDragging:withVelocity:targetContentOffset:")]
>public void ScrollViewWillEndDragging(UIScrollView scrollView, PointF velocity, IntPtr targetContentOffsetPointer)>
>{
>    PointF targetContentOffset = (PointF)Marshal.PtrToStructure(targetContentOffsetPointer, typeof(PointF));
>    PointF adjustedTargetContentOffset = GetAdjustedTargetContentOffset (targetContentOffset, velocity);
>    Marshal.StructureToPtr(adjustedTargetContentOffset, targetContentOffsetPointer, false);
>}

When using the above method to set the targetContentOffset, the scrolling works as expected and the blue boxes are lined up correctly overtime when scrolling ends... as long as the scroll continues after finger removal.

UPDATE: I just tested on device an this issue does not seem to occur on device, so it may be a simulator bug. Asking reporting customer to verify.


## My environment

=== Xamarin Studio ===

Version 5.9 (build 431)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
Runtime:
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

=== Xamarin.Android ===

Version: 5.1.0.115 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 6.3.1 (7703)
Build 6D1002

=== Xamarin.iOS ===

Version: 8.10.0.267 (Business Edition)
Hash: 6481535
Branch: master
Build date: 2015-04-27 04:38:13-0400

=== Xamarin.Mac ===

Version: 2.0.0.262 (Business Edition)

=== Build Information ===

Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 19:25:48-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

=== Operating System ===

Mac OS X 10.10.3
Darwin Jons-iMac.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 1 Jon Goldberger [MSFT] 2015-05-04 16:38:05 UTC
Noting again, as it might have been buried in the description above:

It seems this _may_ be a simulator bug as I was not able to reproduce the issue on device, iPhone 5s running iOS 8.3 but due to the nature of the bug, I may not have tried for long enough to get the incorrect behavior. Asking the customer who reported this issue to verify.
Comment 2 Jon Goldberger [MSFT] 2015-05-04 17:56:35 UTC
Similar bug report:
https://bugzilla.xamarin.com/show_bug.cgi?id=29718
Comment 3 Jon Goldberger [MSFT] 2015-05-04 17:58:12 UTC
Might also be related to:
https://bugzilla.xamarin.com/show_bug.cgi?id=14682
which has been in NEEDINFO state for over a year.
Comment 4 Rolf Bjarne Kvinge [MSFT] 2015-05-05 05:49:11 UTC
*** Bug 29718 has been marked as a duplicate of this bug. ***
Comment 5 Rolf Bjarne Kvinge [MSFT] 2015-05-05 05:50:02 UTC
*** Bug 14682 has been marked as a duplicate of this bug. ***
Comment 6 Rolf Bjarne Kvinge [MSFT] 2015-05-05 08:02:44 UTC
Fixed.

maccore/master: 5e3cc72ee9abb1b06a6796d731b39aedf253c818
Comment 7 Rolf Bjarne Kvinge [MSFT] 2015-05-06 04:49:16 UTC
*** Bug 29779 has been marked as a duplicate of this bug. ***
Comment 8 Rolf Bjarne Kvinge [MSFT] 2015-05-06 05:00:49 UTC
*** Bug 29768 has been marked as a duplicate of this bug. ***
Comment 9 Arpit Jha 2015-05-08 01:28:45 UTC
I have checked this issue with XS 5.9.1(build 3) + XI 8.10.1.38 and now its working fine.

Screencast: http://www.screencast.com/t/Abt54tMQfJhY

Environment Info:
=== Xamarin Studio ===

Version 5.9.1 (build 3)
Installation UUID: 3d25a767-a003-4a7d-9f5e-e57987cf6cf0
Runtime:
 Mono 4.0.1 ((detached/f802480)
 GTK+ 2.24.23 (Raleigh theme)

 Package version: 400010028

=== Apple Developer Tools ===

Xcode 6.3 (7569)
Build 6D570

=== Xamarin.iOS ===

Version: 8.10.1.38 (Enterprise Edition)
Hash: 26b7e3c
Branch: master
Build date: 2015-05-07 20:19:07-0400

=== Xamarin.Android ===

Version: 5.1.1.3 (Enterprise Edition)
Android SDK: /Users/mac360_xamarin/Library/Developer/Xamarin/android-sdk-macosx
 Supported Android versions:
  2.3   (API level 10)
  4.0.3 (API level 15)
  4.4   (API level 19)
  5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.0.1.36 (Enterprise Edition)

=== Build Information ===

Release ID: 509010003
Git revision: 69fbf1e41bf51df2e78e2e1d783873e5741a4603
Build date: 2015-05-07 10:47:40-04
Xamarin addins: e9931adc0294756b9671c4cb9ad8d6c906b678e6

=== Operating System ===

Mac OS X 10.10.0
Darwin mac360-xamarins-Mac-mini.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64