2012-01-13 17 views
5
पर

आईओएस SDK..as में दो fingure स्पर्श मैं जानता हूँ कि यह बहुत आसान है, लेकिन की वजह से मैं इस प्रौद्योगिकी के क्षेत्र में नया हूँ इसलिए नहीं कर सकते समझ में साथ UIImageView को घुमाने के लिए कैसे ...UIRotationGestureRecognizer UIImageView

को UIRotationGestureRecognizer का उपयोग कैसे करें यह लागू ...

कृपया मेरी मदद इस समस्या को हल करने के लिए ...

धन्यवाद।

+0

क्या आप अब तक क्या किया है? क्या आपने यह मार्गदर्शिका पढ़ ली है: http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html#//apple_ref/doc/uid/TP40009541-CH6-SW1 – bandejapaisa

+0

आप निम्नलिखित लिंक देख सकते हैं, http://stackoverflow.com/questions/3448614/uiimageview-gestures-zoom-rotate-question, http://www.icodeblog.com/2010/10/14/working-with-uigesturerecognizers/ – rishi

उत्तर

12

कोड इस दृश्य पर किया था लोड या imageView समारोह बनाने के लिए: m_ctrlImgVwShowImage - अपने के 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]; 
}