我使用以下代码在品牌上显示图像,但出现 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];
Error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [UIImageView _isResizable]: unrecognized selector instance stmt to 0x6b8bb70'
最佳答案
错误发生是因为您试图将 UIImageView 视为 UIImage。
myImageView = [[UIImageView alloc] initWithFrame: rect];
[myImageView setImage: image];
如果错误消失尝试检查
[self.view addsubview:myImageView];
使您的 ImageView 链接到显示屏幕。
如果它仍然没有出现,请尝试检查 ImageView 的图层。
[self.view bringSubviewToFront:myImageView];
关于iphone - UIImageView _isResizable : Unrecognized Selector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10574762/