【问题标题】:image not showing from url of back4app.com(ios)图像未从 back4app.com(ios) 的 url 显示
【发布时间】:2016-10-13 15:13:19
【问题描述】:

我正在使用 sd 网络图像,但在从 back4app.com(解析服务器)获取图像时遇到问题。 我在主线程和没有主线程的情况下使用了下面的代码。 并尝试使用编码和不使用编码。 我从不同的网址获取另一张图片,但未加载来自 back4app.com 的图片。

NSString *sttt2=flel.url;
NSString *str = [[NSString alloc] initWithUTF8String:[sttt2 cStringUsingEncoding:NSUTF8StringEncoding]];

NSURL *url2 = [NSURL URLWithString:str];
dispatch_async(dispatch_get_main_queue(), ^{

        [immg1 sd_setImageWithURL:url2  placeholderImage:[UIImage imageNamed:@"profilemain_blu"]];
            });

【问题讨论】:

  • 您看到占位符图像了吗?在 setImageWithURL 方法中放置一个断点,看看那里发生了什么。
  • 图片未下载
  • 你能贴出实际的网址吗?
  • 试试NSData *data = [NSData dataWithContentOfURL:ulr2],在这种情况下data是零吗?如果不是,如果那么你做UIImage *image = [UIImage imageWithData:data];,是image nil?
  • 在 nsdata 情况下它返回 nil

标签: ios objective-c iphone ipad back4app


【解决方案1】:

在 Parse Server 的 Docs 中有一个上传文件的示例,代码如下:

NSData *imageData = UIImagePNGRepresentation(image);
PFFile *imageFile = [PFFile fileWithName:@"image.png" data:imageData];

PFObject *userPhoto = [PFObject objectWithClassName:@"UserPhoto"];
userPhoto[@"imageName"] = @"My trip to Hawaii!";
userPhoto[@"imageFile"] = imageFile;
[userPhoto saveInBackground];

点击这里阅读更多:http://docs.parseplatform.org/ios/guide/#files

还有一点要检查,是你正在使用的版本,有时与一些错误有关:https://github.com/parse-community/Parse-SDK-iOS-OSX/releases

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-17
    • 1970-01-01
    • 2021-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-05
    相关资源
    最近更新 更多