I'm using this code to stretch an image correctly, however on iOS 5.1 it crashes. If I remove the resizingMode from the end, it works but the image is then tiled and looks funny. Any ideas why it's crashing?
Thanks
self.scrollViewImage.image = [[UIImage imageNamed:@"SysInfoBackBox"] resizableImageWithCapInsets:UIEdgeInsetsMake(40, 40, 40, 40) resizingMode:UIImageResizingModeStretch];
It's a new method introduced in iOS 6.0 and not supported on previous versions. If you want to make the code run on previous versions, you will have to check at runtime if UIImage instance responds to selector for that method and implement alternative if it doesn't.
if ([UIImage instancesRespondToSelector:@selector(resizableImageWithCapInsets:resizingMode:)]) {
self.scrollViewImage.image = [[UIImage imageNamed:@"SysInfoBackBox"] resizableImageWithCapInsets:UIEdgeInsetsMake(40, 40, 40, 40) resizingMode:UIImageResizingModeStretch];
} else {
// alternative
}
This function
resizableImageWithCapInsets:resizingMode:
don't work on ios 5.0 (only >=6.0), but
resizableImageWithCapInsets:
does, try to use it. Maybe a simple replacement can help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With