2012-09-29 34 views

回答

0

此代碼的工作,因爲我需要:

- (IBAction)rorationDid:(UIRotationGestureRecognizer *)recognizer 
{ 
    static CGFloat angle = 0; 
    if (recognizer.state == UIGestureRecognizerStateBegan) 
     angle = recognizer.rotation; 
    if (recognizer.state != UIGestureRecognizerStateEnded) 
     return; 

    float rotation = 0; 
    if (angle - recognizer.rotation > M_PI/8) 
     rotation = -M_PI_2; 
    if (angle - recognizer.rotation < -M_PI/8) 
     rotation = M_PI_2; 

    if (rotation != 0.0) 
    { 
     // Let's do rotation 
    } 
} 

UPDATE:

此代碼:static CGFloat angle = 0;真的應該是一個@propertystatic