Ios – UIImageView _isResizable: Unrecognized Selector

compiler-errorsiosiphoneobjective cuiimageview

I have the following code to display an image on a brand but I get an UIImageView error.
I resize my image of size 800×600 to fit to the size of the screen of the 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'

Best Answer

The Error occur because you attempt to treat UIImageView as an UIImage.

myImageView = [[UIImageView alloc] initWithFrame: rect];
[myImageView setImage: image];

If the error disappear try to check

[self.view addsubview:myImageView];

to make your imageview link to display screen.

If it still not appear try to check layer of your image view.

[self.view bringSubviewToFront:myImageView];
Related Topic