0

I'm trying to control an image. The following lines works:

UIImage *image = [UIImage imageNamed:@"Cloud-Small.png"];

However it I extend it and try and force the size:

UIImage *image = [[UIImage imageNamed:@"Cloud-Small.png"] _imageScaledToSize:CGSizeMake(30.0f, 32.0f) interpolationQuality:1];

I get a

No visible @interface for 'UIIImage' declares the selector 'interpolationQuality'

Any ideas? This line is located in a cellForRowAtIndexPath: method.

Nate
  • 31,017
  • 13
  • 83
  • 207
Edward Hasted
  • 3,201
  • 8
  • 30
  • 48
  • The leading underscore in `_imageScaledToSize` suggests that you're using undocumented API, which will likely also prevent your app from getting approved into the App Store. – DPlusV Jul 15 '12 at 06:09
  • Oh? I copied that line from an example of how to import data into TableViews. Does the underscore always signify a home brew call? For the time being I have just left the working line as is. – Edward Hasted Jul 15 '12 at 09:33
  • possible duplicate of [The simplest way to resize an UIImage?](http://stackoverflow.com/questions/2658738/the-simplest-way-to-resize-an-uiimage) – sanmai Sep 17 '13 at 03:23

1 Answers1

2

The problem is that the _imageScaledToSize:interpolationQuality: method is no longer available in iOS. You probably found it searching around online for code, and found a really old post. I just checked the UIKit/UIImage.h header by dumping the UIKit Framework with class-dump, and there is no private method named _imageScaledToSize:interpolationQuality: in UIImage as of iOS 5.0.

I would bet the iOS public APIs for scaling images would suffice for you, so I'd recommend using one of those. It depends what you're using this image for. Is it in a UIImageView?

Anyway, see this answer for a couple alternatives to the way you're trying to scale, which won't work anymore.

P.S. this is one of the reasons to avoid using private APIs if you can. Even if your app isn't for the App Store, and you don't have to worry about Apple's approval. The API being private means it can, and often will, be changed or removed in a future version of iOS.

Community
  • 1
  • 1
Nate
  • 31,017
  • 13
  • 83
  • 207