0
votes

I have a bug.

UIImage *img = [[UIImage imageNamed:@"bg_message.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(47, 32, 47, 32) resizingMode:UIImageResizingModeStretch];


UIImage *img = [[UIImage imageNamed:@"bg_message.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(47, 32, 47, 32) resizingMode:UIImageResizingModeStretch];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:frame];
[imgView setImage:img];
[imgView setTag:99999999];
[self.view addSubview:imgView];

And just meet os 5, os 6 and 7 pass.

//This is the error message

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage resizableImageWithCapInsets:resizingMode:]: unrecognized selector sent to instance 0xd86c2c0'

i don't understand. Anyone help me, please! Thank you very much!

2

2 Answers

3
votes

-[UIImage resizableImageWithCapInsets:resizingMode:] is available only on or after iOS 6. (Reference: Link)

If you build app with this API in new Xcode, it will show you no warning or error. But when you run the app in iOS 5 devices, it will throw unrecognized selector exception. It is hard to catch such bug. So the best way to test is to run on the iOS 5 simulator / device.

It is a good practice too lookup documentation. Apple wrote the documentation well. You can also learn a lot by reading it.

1
votes

The variant with resizingMode was only added in ios6. If you want to run under ios5 as well, you'll have to check whether that method is available.