【发布时间】:2016-07-21 05:53:38
【问题描述】:
我的应用程序中有一个圆形视图,我正在移动该圆形视图中的一些对象,例如图形,它在 90% 的情况下工作正常,但在某些情况下它不调用 TouchEnded,我的重置图形代码在 TouchEnded方法,所以它在下面某个时候卸载是我的触摸委托方法的代码。
#pragma mark - Touch Events For Rotation of GRAPH
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch* touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.view];
prevAngle = [Utilities angleBetweenPoint:touchPoint toPoint:self.view.center];
/// convert negative angle into positive angle
if(prevAngle < 0){
prevAngle = PI_DOUBLE + prevAngle;
}
//
[_viewStaticRadialPart hideToolTip];
}
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
CGFloat diffAngle, tempCurAngle, tempPrevAngle, curTransformAngle, newTransformAngle;
NSLog(@"touchesMoved");
// Get the only touch (multipleTouchEnabled is NO)
UITouch* touch = [touches anyObject];
// Track the touch
CGPoint touchPoint = [touch locationInView:self.view];
curAngle = [Utilities angleBetweenPoint:touchPoint toPoint:self.view.center];
/// convert negative angle into positive angle
if(curAngle < 0){
curAngle = PI_DOUBLE + curAngle;
}
prevAngle = curAngle;
}
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self resetViewsOnceRotationStops];
}
- (void)touchesCancelled:(nullable NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event
{
[resetViewsAfterTouchStops invalidate];
resetViewsAfterTouchStops = nil;
}
我从昨晚开始就被困在这里,所以我们将不胜感激。
提前致谢。
【问题讨论】:
-
您尝试在 touchesEnded 方法中添加调试点?
-
是的,我尝试调试,它从不调用 TouchEnded,只有最后一个方法调用是 TouchesMoved :(
标签: ios objective-c cocoa-touch touches