SIGABRT 消息仅适用于 iOS5
我的应用程序遇到了奇怪的崩溃,这种情况只发生在 iOS5 上。问题似乎出在我的核心动画方法上,因为当我没有为 aAnimation.repeatCount 或 0 设置任何值时,它正在工作,但是当它旋转时,我使用 get SIGABRT 消息,但出现错误:-[NSConcreteValue doubleValue]:无法识别的选择器发送到当我触摸设备/模拟器屏幕时,实例 0x9628100。
任何帮助将不胜感激
我的视图定义
- (void)loadView { CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; UIView *contentView = [[UIView alloc] initWithFrame:screenRect]; contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.view = contentView; [contentView release]; }
设置子视图子
- (void)setUpPlacardView:(NSInteger)picture { // Create the placard view -- its init method calculates its frame based on its image PlacardView *aPlacardView = [[PlacardView alloc] init:picture asColor:asColor]; aPlacardView.desaturation = kotucHue; self.placardView = aPlacardView; [aPlacardView release]; [self.view addSubview:placardView]; }
视图定义
@interface PlacardView : UIView { UIImage *placardImage; float saturation; UIColor *barva; BOOL switchMode; } @property (nonatomic, retain) UIImage *placardImage; @property (nonatomic) float desaturation; @property (readwrite) BOOL switchMode; // Initializer for this object - (id)init:(NSInteger)picture asColor:(BOOL)farba; @end
并进行旋转
- (void)makeKspinning { // Create a transform to rotate in the z-axis float radians = 3.120; CATransform3D transform; if (rotation) { transform = CATransform3DMakeRotation(radians, 0.0, 0.0, 0.0); } else transform = CATransform3DMakeRotation(radians, 0.0, 0.0, 1.0); CABasicAnimation *aAnimation; aAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; CALayer *pLayer = placardView.layer; aAnimation.toValue = [NSValue valueWithCATransform3D:transform]; aAnimation.duration = spinSpeed; aAnimation.cumulative = YES; aAnimation.repeatCount = HUGE_VALF; [pLayer addAnimation:aAnimation forKey:@"animatePlacardViewToSpin"]; pLayer.opacity = spinOpacity; }
I'm facing a strange crash of my app that occurs only with iOS5. The problem seems to be with my core animation method bellow, because when I set no value for aAnimation.repeatCount or 0 it is working, but when it rotates I use get SIGABRT message with error: -[NSConcreteValue doubleValue]: unrecognized selector sent to instance 0x9628100 when I touch device/simulator screen.
any help will be appreciated
My view definition
- (void)loadView { CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; UIView *contentView = [[UIView alloc] initWithFrame:screenRect]; contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.view = contentView; [contentView release]; }
setting a subView
- (void)setUpPlacardView:(NSInteger)picture { // Create the placard view -- its init method calculates its frame based on its image PlacardView *aPlacardView = [[PlacardView alloc] init:picture asColor:asColor]; aPlacardView.desaturation = kotucHue; self.placardView = aPlacardView; [aPlacardView release]; [self.view addSubview:placardView]; }
SubView definition
@interface PlacardView : UIView { UIImage *placardImage; float saturation; UIColor *barva; BOOL switchMode; } @property (nonatomic, retain) UIImage *placardImage; @property (nonatomic) float desaturation; @property (readwrite) BOOL switchMode; // Initializer for this object - (id)init:(NSInteger)picture asColor:(BOOL)farba; @end
and make rotation
- (void)makeKspinning { // Create a transform to rotate in the z-axis float radians = 3.120; CATransform3D transform; if (rotation) { transform = CATransform3DMakeRotation(radians, 0.0, 0.0, 0.0); } else transform = CATransform3DMakeRotation(radians, 0.0, 0.0, 1.0); CABasicAnimation *aAnimation; aAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; CALayer *pLayer = placardView.layer; aAnimation.toValue = [NSValue valueWithCATransform3D:transform]; aAnimation.duration = spinSpeed; aAnimation.cumulative = YES; aAnimation.repeatCount = HUGE_VALF; [pLayer addAnimation:aAnimation forKey:@"animatePlacardViewToSpin"]; pLayer.opacity = spinOpacity; }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题是您将
toValue
设置为NSValue
,但关键路径是transform.rotation
,这不是一个 NSValue。您应该使用transform
作为 keyPath,或者应该使用transform.rotation.z
(或任何轴)作为 keyPath 和一个简单的NSNumber< /code> 作为您的值。
I think the problem is you're setting the
toValue
to anNSValue
, but the key path istransform.rotation
, which is isn't anNSValue
. You should either be usingtransform
as your keyPath, or you should be usingtransform.rotation.z
(or whatever axis) as the keyPath and a simpleNSNumber
as your value.