- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
基本上,我使用的是 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/
是否可以创建具有可调整大小图像的正确对齐 UIImageView? 我尝试了所有方法(例如图像的二次方等),但无法正常工作。 UIImageView的坐标是: po _Background (UIIm
我尝试弄清楚如何使用 resizableImageWithCapInsets: 在 UIImageView 中使下拉图像适合黑色边框(边框只是为了方便)。 我使用 AutoLayout,_imageV
我想了解 resizableImageWithCapInsets 的工作原理,所以我找到了这张图片 图像的大小是 57x51 所以我创建了这样的图像 image = [[UIImage imageWi
我想拉伸(stretch)尺寸为 170x50 的图像并将其显示在尺寸为 240x140 的 ImageView 中。原始图像如下所示: 我想保留四个角,只拉伸(stretch)中心部分。我使用以下代
我想拍这样的照片: 然后我写了代码: [[[UIImage imageNamed:@"background.png"] resizableImageWithCapInsets:UIEdgeInse
基本上,我使用的是 resizableImageWithCapInsets:UIEdgeInsetsMake。但我不确定这是否是我崩溃的根源。我正在我的表格单元格中添加这些可调整大小的图像。我不太确定
我正在使用自定义背景图像自定义 UISegmentedControl。代码是这样的: UIImage *segmentSelected = [[UIImage imageNamed:@"segcont
我需要为每个单元格创建一个非常复杂的背景图像:http://i.stack.imgur.com/PBL0S.png 它的中心有一个透明的圆圈。我的单元格的高度取决于它的内容——它可能会有所不同。但我需
我最近刚开始使用 iOS 编程,并假设我了解 Objective-C 引用计数,但似乎我没有... >(代码 1 或代码 2)。 我没有使用 ARC(基于 PhoneGap 的项目)。 for(int
好吧,我有一个 UIImageView,我想通过“animationImages”为它的图像设置动画,正如您在此处看到的那样: UIImage *img1 = [[UIImage imageNamed
在我的应用程序中,我以编程方式使用简单的纯色为标签制作背景,例如: - (UIImage*)badgeImage { static UIImage *image = nil; static dispa
我目前正在尝试在 SKSpriteNode 上使用可拉伸(stretch)图像。 通常,可伸缩图像由方法 UIImage::resizableImageWithCapInsets: 返回 所以我写了这
我是 Swift's Apple 的新手。我读过一篇来自 Here 的文章 但不知道如何做那样的事情(或者只是简单地不知道如何在 Swift 中使用 resizableImageWithCapInse
UIImage 的 resizableImageWithCapInsets 方法非常适合带圆角的标准矩形按钮,但我正在尝试创建一个看起来像云的按钮,边缘不均匀。我不太清楚绘制或创建它的最佳方式,或者当
因此,我有一个尺寸为 (640, 960) 像素的 .png 图像。我正在尝试从 .png 创建一个可调整大小的图像,以便垂直拉伸(stretch)该图像并适合 iPhone 5 的(640、1096
我有一个 png 用作另一个图像的图像蒙版。两个图像都有圆角,这些圆角使用 resizableImageWithCapInsets: 保留。图像(不是 mask )会自动调整大小,因为它是 UIPro
我有一个 UIImage 使用 resizableImageWithCapInsets 完美调整大小来制作包含文本标签的角标(Badge)。我很想知道有没有办法在 Storyboard或使用 Nib
我正在编写我的第一个 iOS 应用,目标是 iOS 5.0+ 平台。我正在使用 UIAppearance 协议(protocol)来自定义应用程序 UI。 我正在尝试更改整个应用程序中 UIBarBu
以下代码在指定的插图内平铺图像区域: UIEdgeInsets imgInsets = UIEdgeInsetsMake(10.f, 5.f, 13.f, 44.f); UIImage *image
我正在尝试创建下图的可调整大小版本(40x28,底部的小三角形应水平居中): UIEdgeInsets imageInsets = UIEdgeInsetsMake(4.0f, 4.0f, 8.0f,
我是一名优秀的程序员,十分优秀!