如果用户关闭 displayAlert,如何停止 imagecropper 插件中的 activity 指示器?
how to stop activity indicator in imagecropper plugin, if user closes displayAlert?
问题是 在步骤 #2 中,如果用户不选择选项或只是关闭 displayAlert 而不是 activityIndicator
运行永远。如果用户关闭了 displayAlert(在步骤#2 中),我知道如何停止 Activity Indicator
吗?
下面是您看到的完整代码流程:
- 在主页上 - 使用
activityIndicator
开始加载
- 打开 displayAlert,有 2 个选项:“上传图片”或“拍照”
- 打开相机
- 拍照
- 符合照片
- 转到主页并等待 2 秒(这很糟糕,但还可以)
- 打开裁剪图片编辑器
- 关闭裁剪图像编辑器并转到主页
- 使用
activityIndicator
停止加载
来自 link
的默认代码
//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);
问题是 在步骤 #2 中,如果用户不选择选项或只是关闭 displayAlert 而不是 activityIndicator
运行永远。如果用户关闭了 displayAlert(在步骤#2 中),我知道如何停止 Activity Indicator
吗?
下面是您看到的完整代码流程:
- 在主页上 - 使用
activityIndicator
开始加载
- 打开 displayAlert,有 2 个选项:“上传图片”或“拍照”
- 打开相机
- 拍照
- 符合照片
- 转到主页并等待 2 秒(这很糟糕,但还可以)
- 打开裁剪图片编辑器
- 关闭裁剪图像编辑器并转到主页
- 使用
activityIndicator
停止加载
来自 link
的默认代码 //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);