2012-01-13 32 views
5
üzerinde

... iOS SDK..as iki Fingure dokunuş bu çok basit olduğunu biliyorum ama bu teknolojideki yeni duyuyorum nedeniyle bu anlayamadığım böylece ile UIImageView döndürmek için nasılUIRotationGestureRecognizer UIImageView

için UIRotationGestureRecognizer nasıl kullanılır ...

bana bu sorunu çözmek için yardım edin ...

Teşekkür bu uygularlar.

+0

? Bu kılavuzu okudunuz: http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html#//apple_ref/doc/uid/TP40009541-CH6-SW1 – bandejapaisa

+0

aşağıdaki bağlantılara başvurabilir, http://stackoverflow.com/questions/3448614/uiimageview-gestures-zoom-rotate-question, http://www.icodeblog.com/2010/10/14/working-with-uigesturerecognizers/ – rishi

cevap

12

Kod Bu görüşe yaptığımız yük veya imageview işlevi oluşturun: m_ctrlImgVwShowImage - Şimdiye kadar ne yaptın senin en imageview

UIRotationGestureRecognizer *rotationRecognizer = [[[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)] autorelease]; 
    [rotationRecognizer setDelegate:self]; 
    [m_ctrlImgVwShowImage addGestureRecognizer:rotationRecognizer]; 

//lastRotation is a cgfloat member variable 

-(void)rotate:(id)sender { 
    if([(UIRotationGestureRecognizer*)sender state] == UIGestureRecognizerStateEnded) { 
     _lastRotation = 0.0; 
     return; 
    } 

    CGFloat rotation = 0.0 - (_lastRotation - [(UIRotationGestureRecognizer*)sender rotation]); 

    CGAffineTransform currentTransform = m_ctrlImgVwShowImage.transform; 
    CGAffineTransform newTransform = CGAffineTransformRotate(currentTransform,rotation); 

    [m_ctrlImgVwShowImage setTransform:newTransform]; 

    _lastRotation = [(UIRotationGestureRecognizer*)sender rotation]; 
}