![](/img/trans.png)
[英]Crazy Memory Issues using SDWebImage in a CollectionView (inside a tableviewCell)
[英]Upload image in imageview inside collectionView using sdwebimage
我必須表現出圖像imageView
使用SDWebImage
這是我的代碼:
NSString *string2 = [[dataArray objectAtIndex:indexPath.row ]valueForKey:@"logo"];
[imagev sd_setImageWithURL:[NSURL URLWithString:@"http://dev-demo.info.bh-in-15.webhostbox.net/dv/nationalblack/upload/post/"]
placeholderImage:[UIImage imageNamed:string2]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
imagev.image = image;
}];
我在ImageView
沒有任何圖像
我從服務器獲取的數據是
data array (
{
address = brisbane;
amount = 0;
"business_phone" = 9990688436;
catid = 0;
catname = "";
city = delhi;
contactperson = "Gautam Kumar";
country = Australia;
createdon = 1464935578;
email = "gautam.kumar@eyeforweb.com";
expirydays = 366;
expirymail = 0;
"fb_address" = "";
id = 78;
"inst_address" = "";
isexpired = 0;
isfeatured = 0;
lat = "-33.7961";
"link_address" = "";
lng = "151.146";
logo = "";
longdesc = "xyz ";
mobileno = "";
officephone = "";
ondedaysmail = 0;
"package_name" = 0;
paidamount1 = 0;
paydate1 = 0;
paystatus1 = 1;
"prod_name" = 13;
"pt_address" = "";
sevendaysmail = 0;
shortdesc = hello123;
state = "New South Wales";
status = 1;
tags = "";
"tb_address" = "";
title = aayush;
transcationid1 = "";
"tw_address" = "";
userid = 5;
username = "Gautam Kumar";
"var_name" = 56;
"web_address" = "";
},
{
address = "Address 1";
amount = 0;
"business_phone" = 9990688436;
catid = 0;
catname = "";
city = ABD;
contactperson = "Gautam Kumar";
country = Australia;
createdon = 1464158696;
email = "gautam.kumar@eyeforweb.com";
expirydays = 357;
expirymail = 0;
"fb_address" = "";
id = 75;
"inst_address" = "";
isexpired = 0;
isfeatured = 0;
lat = "-37.488";
"link_address" = "";
lng = "144.592";
logo = "appflowchart_4c1.gif";
longdesc = "This is short Description.";
mobileno = "";
officephone = "";
ondedaysmail = 0;
"package_name" = 0;
paidamount1 = 0;
paydate1 = 0;
paystatus1 = 1;
"prod_name" = 3;
"pt_address" = "";
sevendaysmail = 0;
shortdesc = "This is short Description.";
state = Gisborne;
status = 1;
tags = "";
"tb_address" = "";
title = Business1;
transcationid1 = "";
"tw_address" = "";
userid = 5;
username = "Gautam Kumar";
"var_name" = 0;
"web_address" = "";
},
{
address = "Paschim Vihar ,Delhi";
amount = 0;
"business_phone" = 9990688436;
catid = 0;
catname = "";
city = "New Delhi";
contactperson = "Gautam Kumar";
country = Australia;
createdon = 1464065014;
email = "gautam.kumar@eyeforweb.com";
expirydays = 356;
expirymail = 0;
"fb_address" = Facebook;
id = 72;
"inst_address" = Instagram;
isexpired = 0;
isfeatured = 0;
lat = "-37.488";
"link_address" = linked;
lng = "144.592";
logo = "Screenshot_(1)_61b.png";
longdesc = sdfsdfdsf;
mobileno = "";
officephone = "";
ondedaysmail = 0;
"package_name" = 0;
paidamount1 = 0;
paydate1 = 0;
paystatus1 = 1;
"prod_name" = 3;
"pt_address" = Pinsta;
sevendaysmail = 0;
shortdesc = fffsdf;
state = Gisborne;
status = 1;
tags = "";
"tb_address" = Tumbler;
title = "First business";
transcationid1 = "";
"tw_address" = Twitter;
userid = 5;
username = "Gautam Kumar";
"var_name" = 2;
"web_address" = Website;
},
{
address = Laxminagar;
amount = 0;
"business_phone" = 9990688436;
catid = 0;
catname = "";
city = "New Delhi1";
contactperson = "Gautam Kumar";
country = Australia;
createdon = 1463651418;
email = "gautam.kumar@eyeforweb.com";
expirydays = 7;
expirymail = 0;
"fb_address" = Facebook;
id = 61;
"inst_address" = Instagram;
isexpired = 0;
isfeatured = 0;
lat = "28.6433";
"link_address" = linked;
lng = "77.0363";
logo = "Screenshot_(1)_0ba.png";
longdesc = asxasxasx;
mobileno = "";
officephone = "";
ondedaysmail = 0;
"package_name" = 0;
paidamount1 = 0;
paydate1 = 0;
paystatus1 = 1;
"prod_name" = 3;
"pt_address" = Pinsta;
sevendaysmail = 0;
shortdesc = xasxasx;
state = Victoria;
status = 1;
tags = "";
"tb_address" = Tumbler;
title = "Testing by Gautam";
transcationid1 = 1111111111111;
"tw_address" = Twitter;
userid = 5;
username = "Gautam Kumar";
"var_name" = 2;
"web_address" = Website;
}
)
Aayush Katiyar,
從iOS 8開始,您不應使用http,而應使用安全通道https。 萬一您沒有考慮將這些添加到您的plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
您所有的圖像下載API都在使用http://,我想這可能是這里的問題
最后,將圖像加載方式更改為
[imagev sd_setImageWithURL:[NSURL URLWithString: [NSString stringWithFormat:@"%@/%@",@"http://dev-demo.info.bh-in-15.webhostbox.net/dv/nationalblack/upload/post/", string2]]
placeholderImage:[UIImage imageNamed:@"Some_Placeholder_Image"]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
imagev.image = image;
}];
像這樣使用
[cell.myImageView sd_setImageWithURL:finalImageUrl];
finalImageUrl
是您下載圖像的最終url
。
無需將方法與完成處理程序一起使用。 這是針對不同的任務。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.