C# 如果用户关闭displayAlert,如何停止imagecropper插件中的活动指示器?

C# 如果用户关闭displayAlert,如何停止imagecropper插件中的活动指示器?,c#,xamarin,xamarin.forms,xamarin.android,C#,Xamarin,Xamarin.forms,Xamarin.android,问题在于在第#2步中,如果用户没有选择选项或只是关闭displayAlert,则活动指示器将永远运行。如果用户关闭了displayAlert(在步骤2中),您知道如何停止活动指示器吗 参考: 下面是您看到的完整代码流: 在主页上-使用activityIndicator开始加载 打开displayAlert,有两个选项:“上传图像”或“拍照” 开放式摄像机 拍照 符合照片 转到主页并等待2秒钟(这很糟糕,但还可以) 打开裁剪图像编辑器 关闭裁剪图像编辑器并转到主页面 使用活动指示器停止加载 解除链

问题在于在第#2步中,如果用户没有选择选项或只是关闭displayAlert,则
活动指示器将永远运行。如果用户关闭了displayAlert(在步骤2中),您知道如何停止活动指示器吗

参考:

下面是您看到的完整代码流:

  • 在主页上-使用
    activityIndicator开始加载
  • 打开displayAlert,有两个选项:“上传图像”或“拍照”
  • 开放式摄像机
  • 拍照
  • 符合照片
  • 转到主页并等待2秒钟(这很糟糕,但还可以)
  • 打开裁剪图像编辑器
  • 关闭裁剪图像编辑器并转到主页面
  • 使用活动指示器停止加载
  • 解除链接中的代码

          //run loading if user picked a option
          activityIndicator.IsRunning = true;
    
         //this code always get run last thing in method
            new ImageCropper()
            {
              Success = (imageFile) =>
              {
                 Device.BeginInvokeOnMainThread(() =>
                 {
                   //turn off loading
                   activityIndicator.IsRunning = false;
                   imageView.Source = ImageSource.FromFile(imageFile);
                  });
               }
             }.Show(this);
    

    很抱歉回复太晚,事实上我想把这个放在评论里,但在评论里读起来真的很难。 我想您可以尝试以下代码:

        new ImageCropper()
        {
          Success = (imageFile) =>
          {
             Device.BeginInvokeOnMainThread(() =>
             {
               //turn off loading
               activityIndicator.IsRunning = false;
               imageView.Source = ImageSource.FromFile(imageFile);
              });
           },
           //this 'faiure' is not typo, check ImageCropper.cs in your link
           Faiure = () =>
                {
                    activityIndicator.IsRunning = false;
                }
         }.Show(this);
    

    您是否尝试移动
    activityIndicator.IsRunning=false到下面:
    }.Show(这个)?是的,我试过了,但活动根本没有出现。我能告诉你的是,
    newimagecrapper()
    总是在一种方法中得到最后一件事,你刚刚帮我省去了很多麻烦。谢谢你的解决方案确实有效!!不客气:)