xCode: iPhone Swipe Gesture crash

Posted by David DelMonte on Stack Overflow See other posts from Stack Overflow or by David DelMonte
Published on 2011-02-20T23:22:17Z Indexed on 2011/02/20 23:25 UTC
Read the original article Hit count: 337

I have an app that I'd like the swipe gesture to flip to a second view. The app is all set up with buttons that work. The swipe gesture though causes a crash ( “EXC_BAD_ACCESS”.).

The gesture code is:

- (void)handleSwipe:(UISwipeGestureRecognizer *)recognizer {
    NSLog(@"%s", __FUNCTION__);
    switch (recognizer.direction)
    {
        case (UISwipeGestureRecognizerDirectionRight):
            [self performSelector:@selector(flipper:)];
            break;

        case (UISwipeGestureRecognizerDirectionLeft): 
            [self performSelector:@selector(flipper:)];
            break;

        default:
            break;
    }   
}

and "flipper" looks like this:


- (IBAction)flipper:(id)sender {
    FlashCardsAppDelegate *mainDelegate = (FlashCardsAppDelegate *)[[UIApplication sharedApplication] delegate];
    [mainDelegate flipToFront];
}

flipToBack (and flipToFront) look like this..

- (void)flipToBack {
     NSLog(@"%s", __FUNCTION__);

    BackViewController *theBackView = [[BackViewController alloc] initWithNibName:@"BackView" bundle:nil];
    [self setBackViewController:theBackView];
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES];
    [frontViewController.view removeFromSuperview];
    [self.window addSubview:[backViewController view]];
    [UIView commitAnimations];
    [frontViewController release];
    frontViewController = nil;
    [theBackView release];
    //  NSLog (@" FINISHED ");
}

Maybe I'm going about this the wrong way... All ideas are welcome...

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about xcode