gpt4 book ai didi

ios - 使用 resizableImageWithCapInsets 崩溃 :UIEdgeInsetsMake

转载 作者:行者123 更新时间:2023-11-28 22:40:59 24 4
gpt4 key购买 nike

基本上,我使用的是 resizableImageWithCapInsets:UIEdgeInsetsMake。但我不确定这是否是我崩溃的根源。我正在我的表格单元格中添加这些可调整大小的图像。我不太确定这是怎么发生的。

这是日志。

 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

最佳答案

我遇到了同样的问题,这只发生在使用 iOS5.x 调整 UIImageView 大小的设备上,该 UIImageView 显示以这种方式创建的 UIImage:

    UIEdgeInsets edgeInsets = UIEdgeInsetsMake(topCapHeight, leftCapWidth, topCapHeight, leftCapWidth);
image = [originalImage resizableImageWithCapInsets:edgeInsets];

这可能是一个 iOS 错误,已在 iOS6.x 中修复

如果您的情况是使用镜像标准调整图像大小,您可以使用这种方式:

创建一个 UIImage 类并添加这个实例方法:

- (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;
}

方法: - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight

已在 iOS 文档中弃用,但在框架中未弃用,这意味着您可以在 iOS5.x 设备上运行您的应用程序时毫无问题地使用它,并在 iOS 设备上使用新支持的方法6 或更高。

关于ios - 使用 resizableImageWithCapInsets 崩溃 :UIEdgeInsetsMake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14528388/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com