2011-10-18 72 views
4

我正面臨着我的應用程序的一個奇怪的崩潰,只發生在iOS5上。這個問題似乎與我的核心動畫方法bellow,因爲當我沒有爲aAnimation.repeatCount或0設置值它正在工作,但是當它旋轉我使用獲取SIGABRT消息與錯誤: - [NSConcreteValue doubleValue]:無法識別的選擇器發送到實例0x9628100當我觸摸設備/模擬器屏幕。僅適用於iOS5的SIGABRT消息

任何幫助將不勝感激

我的觀點定義

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

這將有助於,如果你說什麼線它崩潰。 –

+0

它實際上指向「int retVal = UIApplicationMain(argc,argv,nil,@」AppDelegate「);」在我的main.m – Vanya

+0

這只是具有源代碼的頂級框架。回溯會顯示一堆OS功能,我打賭你會發現它在CoreAnimation的中間,試圖訪問動畫對象。 –

回答

3

我認爲這個問題是你的toValue設置到NSValue,但關鍵路徑是transform.rotation,這是不是一個NSValue。您應該使用transform作爲keyPath,或者您應該使用transform.rotation.z(或任何軸)作爲keyPath,並使用簡單的NSNumber作爲您的值。

+1

我嘗試了兩個。第一個沒有旋轉,但沒有崩潰。第二個與之前的iOS4.X一樣工作正常,iOS5通過觸摸屏崩潰。 – Vanya

+0

第二個實際上適合我。感謝名單。 – Vanya