2011-07-11 48 views
0

我正在从网络服务器下载图像(.jpg),然后在UIImageView中将其全屏显示。在模拟器中图像显示正确,但是当我将应用程序加载到iPod(iOS 4.3.2)上时,我得到一个空白页面。我得到的NSData的图像从NSURLConnection的背部,然后用这个代码把它在viewDidLoad中:使用NSURLConnection下载的图像在模拟器上正确显示,而不是在iPod上正确显示

UIImage *map = [UIImage imageWithData:theData]; 
mapView.image = map; 

我MapView的是没有在Interface Builder一个UIView的图像设置。我也有一个工具栏没有显示在设备上,就像它在模拟器上按预期显示的UIImageView一样。有没有人看过类似的行为?

+0

有什么不对您的iPod上的图像? – sergio

+0

据我所知,它只是不显示。 – Millec8

+0

图像有多大?这可能是内存占用问题吗? – sergio

回答

0

我不知道问题是什么,但我放弃了Interface Builder中,并用手添加ImageView的,它现在显示正确。

0

你会用这段代码试试吗?

- (void)viewDidLoad { 
     UIImage *img = [[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://xxxxxxx/xxxx.jpg"]]] retain]; 
     if (img != nil) { 
      mapView.image = img; 
      [img release]; 
    } 
    [super viewDidLoad]; 
} 

这可能是不正常的你,但只是一个try ...

+0

图像不是零,我不想通过使用同步调用阻止主线程。 – Millec8

0

与ARC尝试这种情况:

NSURL * URL = [NSURL URLWithString: @ “http://clasificados.eluniversal.com/imagenes/inmuebles/home/home_inmuebles.jpg”];

UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:url]]; 
if (img != nil) { 
    mapView.image = img; 
    img = nil; 
}