我在使用CGAffineTransformMakeRotation時發生跳躍運動的問題。它似乎工作正常,直到我到達象限1和2的頂部。下面是我使用的代碼和youtube鏈接,顯示發生了什麼。任何洞察力將非常感激。使用CGAffineTransformMakeRotation時的抖動運動
我的目標是旋轉一個UIWebView裏面的svg。由於我無法輕易地在UIWebView上單獨檢測觸摸,所以我在其上放置了一個空白的UIImageView。這使我可以檢測到觸摸並防止彈出複製對話框。
http://www.youtube.com/watch?v=x_OmS0MPdEE&feature=youtu.be
- (void)touchesMoved: (NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
NSArray *allTouches = [touches allObjects];
CGPoint location = [[allTouches objectAtIndex:0] locationInView:self.view];
if(selected == 1) {
CGFloat rads = atan2f(location.y - (grid1.frame.size.height/2),location.x - (grid1.frame.size.width/2));
grid1.transform = grid1Btn.transform = CGAffineTransformMakeRotation(rads);
}
}
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
NSArray *allTouches = [touches allObjects];
CGPoint location = [[allTouches objectAtIndex:0] locationInView:self.view];
if(CGRectContainsPoint(grid1Btn.frame, location))
{
selected = 1;
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
selected = -1;
}
知府,這樣一個簡單的解決方案。非常感謝! 我通過刪除touchesBegan中的變換來阻止它在開始時跳躍。 –