Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[iOS] ActivityIndicator starting animation only when attached to superview #11339

Merged
merged 2 commits into from
Aug 17, 2020
Merged

[iOS] ActivityIndicator starting animation only when attached to superview #11339

merged 2 commits into from
Aug 17, 2020

Conversation

adamped
Copy link
Contributor

@adamped adamped commented Jul 7, 2020

Description of Change

I'm not even sure this is the best way at the moment, but it's a conversation point to move towards a resolution.

The issue comes from having an ActivityIndicator in a CarouselView or UICollectionViewFlowLayout in this case.

You can't call StartAnimating until it has been added to the top UIView (its Superview), otherwise it doesn't do anything. It seems to affect any cell based view, where the cell might not be visible, when the Activity starts its animation.

Issues Resolved

I found this issue locally, in scanning open issues, these could be related

fixes #10377
fixes #1989

API Changes

None

Platforms Affected

  • iOS

Behavioral/Visual Changes

None

Before/After Screenshots

Not applicable

Testing Procedure

Issue:
Put an ActivityIndicator in a CarouselView (not the first one), and when you move to it, it won't be visible, even if running.

With Fix:
It now will keep showing, even if you go away and come back again.

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

You can't start animating the ActivityIndicator if it's not attached to the Superview
public override void LayoutSubviews()
{
base.LayoutSubviews();
if (_element?.IsRunning == true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This triggers when its added to the view

public override void Draw(CGRect rect)
{
base.Draw(rect);
if (_element?.IsRunning == true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't called if it hasn't been triggered by LayoutSubviews() first. But we also need it here, because if you go away then come back again, it needs to call StartAnimating again to redraw it, because it stopped when you move away.

@samhouts
Copy link
Member

Build error: Error CS0246: The type or namespace name 'CGRect' could not be found (are you missing a using directive or an assembly reference?)

Added CoreGraphics namespace
@samhouts samhouts added this to In Review in .NET MAUI Backlog Jul 30, 2020
@samhouts samhouts added the retarget-branch-required PR or associated issues target a milestone. Please target this PR to the matching branch. label Aug 4, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 4, 2020
@samhouts samhouts removed this from In Review in .NET MAUI Backlog Aug 4, 2020
@samhouts samhouts added this to In Review in vNext+1 (5.0.0) Aug 11, 2020
@samhouts samhouts changed the base branch from main to 5.0.0 August 17, 2020 17:59
@samhouts samhouts removed the retarget-branch-required PR or associated issues target a milestone. Please target this PR to the matching branch. label Aug 17, 2020
@samhouts samhouts merged commit 0e97d87 into xamarin:5.0.0 Aug 17, 2020
vNext+1 (5.0.0) automation moved this from In Review to Done Aug 17, 2020
@samhouts samhouts added a/listview Problems with the ListView/TableView a/refreshview 🔄 a/shell 🐚 labels Aug 17, 2020
@samhouts samhouts added this to Done in Sprint 175 Aug 17, 2020
myroot pushed a commit to myroot/Xamarin.Forms that referenced this pull request Aug 19, 2020
…rview (xamarin#11339)

* Update ActivityIndicatorRenderer.cs

You can't start animating the ActivityIndicator if it's not attached to the Superview

* Update ActivityIndicatorRenderer.cs

Added CoreGraphics namespace

fixes xamarin#10377
fixes xamarin#1989
sung-su pushed a commit to sung-su/Xamarin.Forms that referenced this pull request Aug 20, 2020
…rview (xamarin#11339)

* Update ActivityIndicatorRenderer.cs

You can't start animating the ActivityIndicator if it's not attached to the Superview

* Update ActivityIndicatorRenderer.cs

Added CoreGraphics namespace

fixes xamarin#10377
fixes xamarin#1989
sung-su pushed a commit to sung-su/Xamarin.Forms that referenced this pull request Aug 20, 2020
…rview (xamarin#11339)

* Update ActivityIndicatorRenderer.cs

You can't start animating the ActivityIndicator if it's not attached to the Superview

* Update ActivityIndicatorRenderer.cs

Added CoreGraphics namespace

fixes xamarin#10377
fixes xamarin#1989
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants