2015-09-28 117 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>