【发布时间】:2012-05-13 19:59:03
【问题描述】:
我有以下代码可以在品牌上显示图像,但出现 UIImageView 错误。 我调整了大小为 800x600 的图像以适合 iPhone 屏幕的大小。
NSURL * url = [NSURL URLWithString:@"http://www.portallzc.com/galerias/galeria_Portal%20de%20Lazaro%20Cardenas/Club%2033/800/p16jklq9uj1f7a1c6tckkjrg1i8015.JPG"];
NSData * urlData = [NSData dataWithContentsOfURL: url];
UIImage * image = [UIImage imageWithData: urlData];
CGRect rect = CGRectMake (0.0f, 40.0f, image.size.width, image.size.height);
image = [[UIImageView alloc] initWithFrame: rect];
[setImage image: image];
错误:由于未捕获的异常而终止应用程序 'NSInvalidArgumentException',原因:'- [UIImageView _isResizable]: 无法识别的选择器实例 stmt 到 0x6b8bb70'
【问题讨论】:
-
什么是[setImage image: image]; ?你的对象叫 setImage 吗?好坏的名字
-
对不起是:image = [[UIImageView alloc] initWithFrame: rect]; [图像集图像图像:图像];
-
为什么要设置 imageView 的图像等于 imageView 本身?
-
不过,该签名不是有效的语法。
-
我有:NSURL * url = [NSURL URLWithString:@"portallzc.com/galerias/galeria_Portal%20de%20Lazaro%20Cardenas/…; NSData * urlData = [NSData dataWithContentsOfURL: url]; UIImage * image = [UIImage imageWithData: urlData]; CGRect rect = CGRectMake (0.0f, 40.0f, image.size.width, image.size.height); imagen = [[UIImageView alloc] initWithFrame: rect]; [imagen setImage: imagen];
标签: iphone objective-c ios uiimageview compiler-errors