我現在用的是CrossDownManager
插件Xamarin窗體 Here 當我運行在Android上它處理預期的方法。在iOS上,Debug.Writeline("Success!")
不會像在Android上那樣受到打擊。Xamarin形式 - iOS設備不處理正確
下面是代碼:
void ViewImage(string imageLink)
{
var downloadManager = CrossDownloadManager.Current;
downloadManager.PathNameForDownloadedFile = new System.Func<IDownloadFile, string>(file =>
{
string path = DependencyService.Get<IImageSaver>().Save("YHTS" + DateTime.Today.Ticks.ToString() + ".jpg");
Debug.WriteLine("Success!");
return path;
});
try
{
var file = downloadManager.CreateDownloadFile(imageLink);
Debug.WriteLine("file created");
downloadManager.Start(file);
Debug.WriteLine("downloadstarted");
}
catch (Exception e)
{
Debug.WriteLine(e.ToString());
}
}
對我的生活中,我想不通,爲什麼不處理該代碼塊。有任何想法嗎?