Reputation: 3121
Basically, I am using resizableImageWithCapInsets:UIEdgeInsetsMake. But I am not sure if this is the source of my crash. I am adding these resizable images on my table cell. I am not exactly sure on how this is occuring.
Here's the log.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xa1eab0c4
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x3966c5d0 objc_msgSend + 16
1 Foundation 0x3aa1750c probeGC + 60
2 Foundation 0x3aa1d526 -[NSConcreteMapTable removeObjectForKey:] + 30
3 UIKit 0x39e9f46c -[_UIImageViewPretiledImageWrapper dealloc] + 76
4 libobjc.A.dylib 0x3966e490 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 164
5 CoreFoundation 0x3a72882c _CFAutoreleasePoolPop + 12
6 Foundation 0x3aa12e10 -[NSAutoreleasePool release] + 116
7 UIKit 0x39b0f80c -[UITableView layoutSubviews] + 220
8 UIKit 0x39acb892 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 254
9 QuartzCore 0x37fce4e6 -[CALayer layoutSublayers] + 210
10 QuartzCore 0x37fce088 CA::Layer::layout_if_needed(CA::Transaction*) + 456
11 QuartzCore 0x37fcefac CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 12
12 QuartzCore 0x37fce996 CA::Context::commit_transaction(CA::Transaction*) + 234
13 QuartzCore 0x37fce7a8 CA::Transaction::commit() + 312
14 QuartzCore 0x37fce60c CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 56
15 CoreFoundation 0x3a7ba93e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
16 CoreFoundation 0x3a7b8c34 __CFRunLoopDoObservers + 272
17 CoreFoundation 0x3a7b8f8e __CFRunLoopRun + 742
18 CoreFoundation 0x3a72c238 CFRunLoopRunSpecific + 352
19 CoreFoundation 0x3a72c0c4 CFRunLoopRunInMode + 100
20 GraphicsServices 0x37a65336 GSEventRunModal + 70
21 UIKit 0x39b1c28c UIApplicationMain + 1116
Upvotes: 0
Views: 1834
Reputation: 8029
Just FYI.
I also had a crash similar to this and the fix was actually not in the code, but in the asset itself.
As Apple Documentation states the resizable area of the asset needs to be 1px by 1px, so ensure that it is.
- (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets
During scaling or resizing of the image, areas covered by a cap are not scaled or resized. Instead, the pixel area not covered by the cap in each direction is tiled, left-to-right and top-to-bottom, to resize the image. This technique is often used to create variable-width buttons, which retain the same rounded corners but whose center region grows or shrinks as needed. For best performance, use a tiled area that is a 1x1 pixel area in size.
Upvotes: 0
Reputation: 788
I had the same problem, this was happening only with devices with iOS5.x resizing an UIImageView that diplay an UIImage created in this way:
UIEdgeInsets edgeInsets = UIEdgeInsetsMake(topCapHeight, leftCapWidth, topCapHeight, leftCapWidth);
image = [originalImage resizableImageWithCapInsets:edgeInsets];
this is probably an iOS bug that has been fixed in iOS6.x
if your case is resizing the image with a mirror criteria you can use this way:
create a category of UIImage and add this instance method:
- (UIImage*)resizableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight </b>
{
UIImage *image = nil;
float osVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (osVersion < 6.0) {
image = [self stretchableImageWithLeftCapWidth:leftCapWidth topCapHeight:topCapHeight];
} else {
UIEdgeInsets edgeInsets = UIEdgeInsetsMake(topCapHeight, leftCapWidth, topCapHeight, leftCapWidth);
image = [self resizableImageWithCapInsets:edgeInsets];
}
return image;
}
the method :
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight
has been deprecated in the iOS documentation but not in the framework, this mean that you can use it when you are running your app in a device whit iOS5.x without any problem, and user the new supported method with devices with iOS 6 or higher.
Upvotes: 2