iOS updateTopViewHorizontalCenterWithRecognizer EXC_BAD_ACCESS

1

I couldn't find why my app is crashing when the method updateTopViewHorizontalCenterWithRecognizer is called.

Any idea how to fix the error causing the app crash?

Error Log

Crashed: com.apple.main-thread 
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x0000000d

Thread : Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x39400626 objc_msgSend + 5
1  UIKit                          0x3152000d _UIGestureRecognizerSendActions + 196
2  UIKit                          0x313cb503 -[UIGestureRecognizer         _updateGestureWithEvent:buttonEvent:] + 1138
3  UIKit                          0x31772af5 ___UIGestureRecognizerUpdate_block_invoke + 48
4  UIKit                          0x31392373     _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 218
5  UIKit                          0x31390abb _UIGestureRecognizerUpdate + 282
6  CoreFoundation                 0x2eb492a5 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
7  CoreFoundation                 0x2eb46c49 __CFRunLoopDoObservers + 284
8  CoreFoundation                 0x2eb46f8b __CFRunLoopRun + 730
9  CoreFoundation                 0x2eab1f0f CFRunLoopRunSpecific + 522
10 CoreFoundation                 0x2eab1cf3 CFRunLoopRunInMode + 106
11 GraphicsServices               0x33a0a663 GSEventRunModal + 138
12 UIKit                          0x313fd16d UIApplicationMain + 1136

Code, When user swipe from left to right this method is called to show the menu on left side

- (void)updateTopViewHorizontalCenterWithRecognizer:(UIPanGestureRecognizer *)recognizer
{
  //trying to avoid a error
  if( recognizer == nil ) return;

  CGPoint currentTouchPoint     = [recognizer locationInView:self.view];
  CGFloat currentTouchPositionX = currentTouchPoint.x;

  if (recognizer.state == UIGestureRecognizerStateBegan) {
    self.initialTouchPositionX = currentTouchPositionX;
    self.initialHoizontalCenter = self.topView.center.x;
  } else if (recognizer.state == UIGestureRecognizerStateChanged) {

    CGPoint translation = [recognizer translationInView:self.view];

    if(fabs(translation.x) > fabs(translation.y))
    {
      CGFloat panAmount = self.initialTouchPositionX - currentTouchPositionX;
      CGFloat newCenterPosition = self.initialHoizontalCenter - panAmount;

      ...

      [self topViewHorizontalCenterWillChange:newCenterPosition];
      [self updateTopViewHorizontalCenter:newCenterPosition];
      [self topViewHorizontalCenterDidChange:newCenterPosition];
    }
  } else if (recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled) {
    CGPoint currentVelocityPoint = [recognizer velocityInView:self.view];
    CGFloat currentVelocityX     = currentVelocityPoint.x;

    if ([self underLeftShowing] && currentVelocityX > 100) {
      [self anchorTopViewTo:ECRight];
    } else if ([self underRightShowing] && currentVelocityX < 100) {
      [self anchorTopViewTo:ECLeft];
    } else {
      [self resetTopView];
    }
  }
}
ios
ecslidingviewcontroller
asked on Stack Overflow Jun 3, 2014 by fpauer

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0