我正面临着我的应用程序的一个奇怪的崩溃,只发生在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;
}
1 回答
我认为问题是你将
toValue
设置为NSValue
,但关键路径是transform.rotation
,这不是NSValue
. 您应该使用transform
作为keyPath,或者您应该使用transform.rotation.z
(或任何轴)作为keyPath,并使用简单的NSNumber
作为您的值 .