【问题标题】:UIImageView web images are not displayed on XCode 7UIImageView 网络图像不显示在 XCode 7 上
【发布时间】:2015-09-28 12:12:06
【问题描述】:

今天我已将我的项目从 XCode 6 转移到 XCode 7。之前它运行良好,但现在我遇到了一些奇怪的问题。

我在 UIImageView 上显示图像,并且该图像是从网络下载的。代码如下:

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^{
    NSData *data = [NSData dataWithContentsOfURL:imageURL];
    UIImage *image = [UIImage imageWithData:data];
    dispatch_async(dispatch_get_main_queue(), ^{
        [cell.imgTrainer setImage:image];
        selectedTrainerImage = image;
    });
});

我已经检查了imageURL,没问题。

我正在使用presentViewController 调用页面

UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
UIViewController* controller = [storyboard instantiateViewControllerWithIdentifier:@"TrainerListView"];

self.animationController = [[ZoomAnimationController alloc] init];

controller.transitioningDelegate  = self;
[self presentViewController:controller animated:YES completion:nil];

我不明白是什么问题。我什至没有触及 XCode 6 的工作内容。

【问题讨论】:

标签: ios objective-c xcode uiimageview xcode7


【解决方案1】:

暂时你可以将密钥添加到 plist。但它不安全。

http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/

<key>NSAppTransportSecurity</key> <dict> <!--Include to allow all connections (DANGER)--> <key>NSAllowsArbitraryLoads</key> <true/> </dict>

【讨论】:

    【解决方案2】:

    要解决应用传输安全问题,您有两种选择:

    • 使 API 通过 HTTPS 工作
    • 将这行代码粘贴到您的info.plist 中,并继续像升级到 Xcode 7 之前一样使用您的应用:

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

    【讨论】:

      猜你喜欢
      • 2019-04-11
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-21
      • 2013-05-13
      相关资源
      最近更新 更多