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

  • Home
  • SEARCH
  • 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 9227089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:59:02+00:00 2026-06-18T04:59:02+00:00

In my didFinishLaunchingWithOptions method i create GLKView and UIButton as subview. My code: EAGLContext

  • 0

In my didFinishLaunchingWithOptions method i create GLKView and UIButton as subview. My code:

    EAGLContext *context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
    [EAGLContext setCurrentContext:context];

    view = [[GLKView alloc] initWithFrame:[[UIScreen mainScreen] bounds] context:context];
    view.delegate = self;

    btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn setFrame:CGRectMake(5, 50, 200, 50)];
    [btn setTitle:@"Run animation" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(buttonClickHandler:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:btn];

    controller = [[GLKViewController alloc] init];
    controller.delegate = self;
    controller.view = view;

    tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapHandler:shouldReceiveTouch:)];
    tapRecognizer.delegate = self;
    [view addGestureRecognizer:tapRecognizer];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.rootViewController = glController;
    [self.window makeKeyAndVisible];

view, controller, btn are member variables in my AppDelegate class.

I use tapHandler:shouldReceiveTouch: selector because i don’t want to process taps on button, so i do this:

- (BOOL) tapHandler:(UIGestureRecognizer *)recognizer shouldReceiveTouch:(UITouch *)touch
{
    if ([touch.view isKindOfClass:[UIButton class]])
        return NO;
    else
    {
        // some logic ...

        return YES;
    }
}

Problem is when i trying to read touch.view property i get EXC_BAD_ACCESS. What is the reason and how i can avoid it?

  • 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-18T04:59:04+00:00Added an answer on June 18, 2026 at 4:59 am

    The signature of the gesture recognizer target is wrong. It should be in the same form like the UIButton target, i.e. have exactly one argument. The method is then called when a tap gesture is recognized.

    Your method tapHandler:shouldReceiveTouch: belongs to the gesture recognizer delegate.

    EDIT: Don’t worry about the button. The tap won’t recognize when the button is pressed, so you don’t need this delegate method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create a new View-based Application project and modify the didFinishLaunchingWithOptions: method as follow.
I create a new View-based Application project and modify the didFinishLaunchingWithOptions: method as follow.
My appDelegate, in the method didFinishLaunchingWithOptions I load my view controller then create a
I've enabled ARC, In my didFinishLaunchingWithOptions method, I wrote the following code: AppDelegate.h: @interface
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
I have a NSTimer that I create when entering method - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; //
I'm having some problems in passing context from the app delegate to the view
I'm trying to create a container view controller to hold a UINavigationController and a
In MyappAppDelegate.m file at application: didFinishLaunchingWithOptions: method, I just wrote: NSDateFormatter *df = [[NSDateFormatter

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.