XCode 7 上不显示 UIImageView 网络图像
UIImageView web images are not displayed on XCode 7
今天我将我的项目从 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.
的任何一行
要解决 App Transport Security 问题,您有两种选择:
- 使 API 通过 HTTPS 工作
将这行代码粘贴到您的 info.plist
中,然后像升级到 Xcode 7:
之前一样继续使用您的应用程序
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
暂时可以将密钥添加到 plist.But 它不安全。
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>
今天我将我的项目从 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.
的任何一行要解决 App Transport Security 问题,您有两种选择:
- 使 API 通过 HTTPS 工作
将这行代码粘贴到您的
之前一样继续使用您的应用程序info.plist
中,然后像升级到 Xcode 7:<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
暂时可以将密钥添加到 plist.But 它不安全。
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>