ios - XCode 7 上不显示 UIImageView 网络图像

标签 ios objective-c xcode uiimageview xcode7

今天我已经将我的项目从 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 上运行的任何一行。

最佳答案

对于临时,您可以将 key 添加到 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>

enter image description here

关于ios - XCode 7 上不显示 UIImageView 网络图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32822691/

相关文章:

xcode - 使用 Mac Catalyst 上传新应用程序版本时出错

ios - 从另一个 View Controller 检索 SQLite 数据

iOS Swift,UITableView 中的单元格不占据整个宽度

ios - ip camera feed 到 IOS 应用程序如何允许全局连接?

iphone - 如何动态添加Section和TableView Cell

swift - Word "func"有破折号下划线但没有错误

ios - Dispatch_Group 在 iPhone 4s/iOS 8 上崩溃

ios - 带有 NSOperation 的 MagicalRecord 导致持久性问题

ios - UITableView 单元格被发送 setSelected :NO during layoutView

swift - 有什么方法可以用 swiftUI 获取 gif 作为背景吗?