简体   繁体   English

使用sdwebimage在collectionView内的imageview中上传图像

[英]Upload image in imageview inside collectionView using sdwebimage

I have to show image in imageView using SDWebImage 我必须表现出图像imageView使用SDWebImage

Here is my code: 这是我的代码:

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;
 }];

I am not getting any image inside ImageView 我在ImageView没有任何图像

data I am getting from the server is 我从服务器获取的数据是

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, Aayush Katiyar,

From iOS 8 onwards you are not supposed to use http you should make use of secure channels https. 从iOS 8开始,您不应使用http,而应使用安全通道https。 In case you dont have one consider adding these to your plist 万一您没有考虑将这些添加到您的plist

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

All your image download api is making use of http:// I guess that might be the issue here 您所有的图像下载API都在使用http://,我想这可能是这里的问题

Finally change the way you load the image as 最后,将图像加载方式更改为

[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;
 }];

Just use like this, 像这样使用

 [cell.myImageView sd_setImageWithURL:finalImageUrl];

finalImageUrl is your final url for download image. finalImageUrl是您下载图像的最终url

No need to use method with completion handlerl. 无需将方法与完成处理程序一起使用。 it is for different task. 这是针对不同的任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM