0
URL이 헤더와 함께 다운로드되는 이미지가있는 셀이있는 UICollectionView가 있습니다. 나는 다음과 같이한다 : -SDWebImageDownloader가 포함 된 UICollectionView의 스크롤 이미지로드 및로드 Xamarin
internal void UpdateCell(ProfileValues mdata)
{
var mUrl = "someurl";
var manager = SDWebImageManager.SharedManager;
manager.ImageCache.MaxCacheAge = 86400;
SDWebImageDownloader mDownloader = manager.ImageDownloader;
var authToken = "SomeToken"";
mDownloader.SetHttpHeaderValue(authToken, "Authorization");
mDownloader.SetHttpHeaderValue("application/json; odata=verbose", "Accept");
mDownloader.SetHttpHeaderValue("f", "X-FORMS_BASED_AUTH_ACCEPTED");
try
{
mDownloader.DownloadImage(
url: new NSUrl(mUrl),
options: SDWebImageDownloaderOptions.ProgressiveDownload,
progressBlock: (receivedSize, expectedSize) =>
{
// Track progress...
},
completedBlock: (image, data, error, finished) =>
{
if (image != null && finished)
{
InvokeOnMainThread(() =>
{
this.imgProfilePic.Image = image;
});
}
if (error != null)
{
InvokeOnMainThread(() =>
{
this.imgProfilePic.Image = errorImage;
this.imgProfilePic.BackgroundColor = UIColor.FromRGB(52, 31, 71);
//this.imgProfilePic.Layer.CornerRadius = this.imgProfilePic.Frame.Size.Width/2;
this.imgProfilePic.ClipsToBounds = true;
this.imgProfilePic.Layer.BorderWidth = 3.0f;
this.imgProfilePic.Layer.BorderColor = UIColor.White.CGColor;
});
}
}
);
}
catch (Exception ex)
{
}
}
그러나 모든 스크롤마다 셀이 다시로드되고 이미지가 매번 다운로드된다. 스크롤 할 때 캐시에서 이미지를 캐싱하고 이미지를로드하려면 어떻게합니까? 어떤 도움을 주셔서 감사합니다.
감사 클래스 cachedImage 장소를 사용 &. 요청과 함께 일부 헤더를 전달해야합니다. 어떻게해야합니까? –
이미지 URL로로드 한 헤더를 표시하고 싶습니까? 특정 이미지의 파일 이름과 비슷합니까? – imrohit
아니요. 이미지를 다운로드 할 때 url을 다운로드하여 인증 토큰을 전달하고 싶습니다. –