On iOS, cells aren't highlighted on touch-down when the ListView's CachingStrategy is set to RecycleElement. Works fine on Android and with RetainElement.
CachingStrategy to RecycleElementThe cell should highlight like it does when using RetainElement.
The cell is highlighted (default grey color) only on touch-up when ItemSelected event is also triggered.
As an additional note, there are three different behaviors, one for each CachingStrategy:
After a deep dive into the Xamarin Forms code I have come up with this
My guess on why RecycleElement works differently comes down to this.
Whatever happens to RecycleElement the native Gesture selection is broken for whatever reason. Now the devs must have recognized this because if we trace the code we see that they actually implement a TapGestrueReconizer and add it to the UITableView when recycleelement is used. Now this TapGestureReconizer only sends touch's to the ViewCell using the ShouldReceiveTouch delegate method. But this data is only sent at the end of a Touch, its how TapGestureRecognizer works.
My workaround is simple, call this on TouchesBegan, thereby selecting the row at the beginning of the touch
I've tested this and it works, but I'm not an expert on the code so I'm not sure if this is the best soltuion, but it does show what the issue is and around how it can be solved
if we go to \Xamarin.Forms\Xamarin.Forms.Platform.iOS\ContextActionCell.cs
Scroll down near the bottom to
private class SelectGestureRecognizer : UITapGestureRecognizer
and add this code
public override void TouchesBegan(NSSet touches, UIEvent evt)
{
Tapped(this);
base.TouchesBegan(touches, evt);
}
it will fix the select issue
I have a local branch created with a fix. I have created the UI test case to go along with it, but I do not have access to push a branch to this repo. Can someone help me out so I can create the PR?
@v-haroha That's awesome to hear!!
you need to fork this repository and then create a branch on your own fork. Then from there you can create a pull request
https://help.github.com/en/articles/fork-a-repo
https://help.github.com/en/articles/creating-a-pull-request-from-a-fork
Had to reopen this issue since I reverted ( #7787 ) the pr that was merged because it doesn't fix the issue on iOS13 and was causing issues with context actions not working, or having multiple selected rows at the same time

@rmarinho There is another issue open regarding iOS13 and highlighting.
Highlighting on iOS13 doens't work at all, this is a separate matter.
@v-haroha oh, do we have an issue for that? I wasn't aware, but still the other PR broke the context actions so we need to make sure we have a fix for iOS12 or 11 that doesn't break context actions.
But I do think we might need a better approach to make it work in all versions
this is the background color issue for iOS13
https://github.com/xamarin/Xamarin.Forms/issues/7680
its a completely different issue then this.
How are Context Actions broken with this change?
Run the issue Bugzilla45027 in our gallery, if you open the context actions click action, and try to open context action again in the same sell it doesn't open again.
It was failing in our UITests
Thanks, I'll check this out.
We can fix the Context actions, but the highlighting solution that I implemented will work for iOS 13 when the other issue has been resolved. Highlighting isnt working for any listview in iOS13, regardless of recycle element or not.
I don't think this Context not working is related to my changes. I took the current branch and removed all my changes, which isnt hard given that I tried to change as little as possible, and the LongPress Reveal for Bug45027 still does not work.
I took this a step further and modified the test for Bug45027 so the list view will use RetainElement, still had the same results. Would you be available over Slack to talk about this?
So I rolled back to an older Version, beta-4.1.0-pre2

And Long Press to reveal for 45027 still does not work. I think you should probably open a new issue, as whatever is going on here is buried under a mountain of updates and changes.