5
如何有兩個fingure觸摸iOS中SDK..as我知道這是很簡單的,但因爲我在這個技術很新,所以無法理解旋轉的UIImageView ...UIRotationGestureRecognizer上的UIImageView
如何使用UIRotationGestureRecognizer來執行此...
請幫我解決這個問題...
謝謝。
如何有兩個fingure觸摸iOS中SDK..as我知道這是很簡單的,但因爲我在這個技術很新,所以無法理解旋轉的UIImageView ...UIRotationGestureRecognizer上的UIImageView
如何使用UIRotationGestureRecognizer來執行此...
請幫我解決這個問題...
謝謝。
代碼這個觀點上沒有負載或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];
}
你有什麼迄今所做?您是否閱讀過本指南:http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html#//apple_ref/doc/uid/TP40009541-CH6-SW1 – bandejapaisa 2012-01-13 15:56:15
您可以參考以下鏈接,http://stackoverflow.com/questions/3448614/uiimageview-gestures-zoom-rotate-question,http://www.icodeblog.com/2010/10/14/working-with-uigesturerecognizers/ – rishi 2012-01-13 16:52:40