使用 NSURLConnection 下载的图像在模拟器上正确显示,但在 iPod 上根本不显示
我正在从网络服务器下载图像 (.jpg),然后在 UIImageView 中全屏显示它。在模拟器中,图像显示正确,但当我在 iPod (iOS 4.3.2) 上加载应用程序时,我得到一个空白的白页。我从 NSURLConnection 获取图像的 NSData,然后使用以下代码将其设置在 viewDidLoad 中:
UIImage *map = [UIImage imageWithData:theData];
mapView.image = map;
我的 mapView 在 Interface Builder 的 UIView 中设置为没有图像。我还有一个未在设备上显示的工具栏,例如 UIImageView,它按预期显示在模拟器上。有人见过类似的行为吗?
I'm downloading an image (.jpg) from a webserver and then displaying it full screen in an UIImageView. In the simulator the image is displayed correctly, but when I loaded the application on an iPod (iOS 4.3.2) I get a blank white page. I get the NSData for the image back from the NSURLConnection and then set it in viewDidLoad with this code:
UIImage *map = [UIImage imageWithData:theData];
mapView.image = map;
My mapView is setup without an image in a UIView in Interface Builder. I also have a toolbar that isn't showing on the device, like the UIImageView it shows up as expected on the simulator. Has anyone seen similar behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你会尝试使用这段代码吗?
这可能不适合你,但只是尝试一下......
Would you try with this code?
It is possibly not ok for you, but just for a try...
我不确定问题是什么,但我放弃了 Interface Builder 并手动添加了 ImageView,现在它显示正确了。
I'm not sure what the problem was but I abandoned the Interface Builder and added the ImageView by hand and it now shows up correctly.
尝试使用 ARC:
NSURL *url = [NSURL URLWithString:
@“http://clasificados.eluniversal.com/imagenes/inmuebles/home/home_inmuebles.jpg”];
Try this with ARC:
NSURL *url = [NSURL URLWithString:
@"http://clasificados.eluniversal.com/imagenes/inmuebles/home/home_inmuebles.jpg"];