我正在开发我的第一个 IOS 应用程序。该应用程序通过 PHP 网页从数据库下载并显示数据。这一切都很好。我还从同一个 Web 服务器抓取图像以显示在 UIImageView 中。这一切都在模拟器上运行良好。
在我的测试设备(3GS)上,一切正常,除了我无法将下载的图像显示在我的 UIImageView 中。
如果没有互联网连接,我可以在模拟器和设备上显示我包含在应用程序包中的备用图像。
// Inside My data class Implementation
- (void)setUpTheData
{
--- other code ---
NSURL *myImageURL = [NSURL URLWithString:myImageURLString];
NSData *myImageRawData = [NSData dataWithContentsOfURL:myImageURL];
self.myImageData = myImageRawData;
}
- (NSData*)getTheImageData
{
return _myImageData;
}
// Inside my viewDidLoad
UIImage *theImage = [UIImage imageWithData:[theRemoteData getTheImageData]];
_testImage.image = theImage;
我比较了模拟器和设备的图像数据,它们是相同的。