2015-09-28 59 views
0

今天我已经将我的项目从XCode 6移到了XCode 7上。在它完美工作之前,我现在遇到了一些奇怪的问题。UIImageView网页图像不会显示在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

+3

它是HTTPS?可能是因为App Transport Security(https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/) –

+0

这是另一个很好的例子,为什么不使用'WithContentsOfURL:'方法。使用'NSURLSession'是因为没有办法检测'WithContentsOfURL:' – rckoenes

回答

2

解决您与App交通运输安全问题,你有两个选择:

  • 使API工作通过HTTPS
  • 粘贴此行代码放到你的info.plist并继续使用您的应用程序,你在升级前使用Xcode的7:

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