【发布时间】: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 的工作内容。
【问题讨论】:
-
是 HTTPS 吗?可能是因为 App Transport Security (developer.apple.com/library/prerelease/ios/technotes/…)
-
这是另一个很好的例子,为什么不使用
WithContentsOfURL:方法。使用NSURLSession因为无法检测WithContentsOfURL:上的下载错误
标签: ios objective-c xcode uiimageview xcode7