Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8373619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:43:22+00:00 2026-06-09T14:43:22+00:00

Using the GestureRecognizer attached to a view triggers my app to crash with EXC_BAD_ACCESS

  • 0

Using the GestureRecognizer attached to a view triggers my app to crash with EXC_BAD_ACCESS error. Here’s the classes involved

• BoardViewController – Displaying a board (as background) set as rootViewController in the AppDelegate. It instantiates multiple objects of the “TaskViewcontroller”.

//BoardViewController.h
@interface BoardViewController : UIViewController {
    NSMutableArray* allTaskViews; //for storing taskViews to avoid having them autoreleased
}

 

//BoardViewController.m - Rootviewcontroller, instantiating TaskViews    
- (void)viewDidLoad
{
    [super viewDidLoad];
    TaskViewController* taskA = [[TaskViewController alloc]init];
    [allTaskViews addObject:taskA];
    [[self view]addSubview:[taskA view]];
}

• TaskViewController – An indivual box displayed on the board. It should be draggable. Therefore I attached UIPanGestureRecoginzer to its view

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIPanGestureRecognizer* panRecognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)];
    [[self view] addGestureRecognizer:panRecognizer];
}

- (void)handlePan:(UIPanGestureRecognizer *)recognizer {
    NSLog(@"PAN!");
}

The .xib file is a simple view.

enter image description here

All programming with the gesture recognizer I’d prefer to do in code. Any idea how to fix the error causing the app crash?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:43:23+00:00Added an answer on June 9, 2026 at 2:43 pm

    The method handlePan is on your view controller, not on your view. You should set the target to self:

    UIPanGestureRecognizer* panRecognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)];
    

    EDIT (in response to the edit of the question) As omz has correctly noted, your TaskViewController gets released upon BoardViewController‘s viewDidLoad: exit. There are two ways of dealing with it:

    • Fold the handlePan method into the parent view controller, along with the code of viewDidLoad:, or
    • Make an instance variable for TaskViewController *taskA, rather than making it a local variable.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view with a custom slider. We are using a subclass of
I am trying to write an iPhone app using Delphi XE2 / FireMonkey and
Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
I'm using TTLauncherView as a sort of home screen for my app and I
I'm working in an iPad app that has a split view with a navigation
I have a dynamically created list of labels and I am using GestureRecognizer for
I am using : UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleViewClicked:)]; [tmp addGestureRecognizer:gestureRecognizer]; [gestureRecognizer
(Using iOS 5 and Xcode 4.2.) I've followed the instructions here: http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html#//apple_ref/doc/uid/TP40009497-CH6-SW15 and used
I'm using a tap gesture recognizer to position a little subview with a label

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.