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 7694727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:23:05+00:00 2026-05-31T21:23:05+00:00

I want to create an animated menu. first it’s hidden outside screen when user

  • 0

I want to create an animated menu.

  • first it’s hidden outside screen
  • when user taps the screen, it will slide in
  • user can tap it and it do something
  • then after 3s it will slide outside screen

But problem is it not response when I tap it. Why?

example code: All code is in my UIView class.

showing = NO;
box = [[UIView alloc] initWithFrame:CGRectMake(500,-200,200,200)];
box.backgroundColor = [UIColor redColor];

UITapGestureRecognizer *tapBox = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapMenuHandler:)] autorelease];
[box addGestureRecognizer:tapBox];

[self addSubView:box];

and:

-(void) tapMenuHandler: (UIView *)obj {
    //Do something
    NSLog(@"tap box");
} 

and:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if (!showing) {

    box.frame = CGRectMake(500, -200, 200, 200);

    [UIView animateWithDuration:0.5f delay:0.3f options:(UIViewAnimationOptionAllowUserInteraction) animations:^{

        box.frame = CGRectMake(500, 200, 200, 200);

    } completion:^(BOOL finished) {
        showing = YES;

                    [UIView animateWithDuration:0.5f delay:3.0f options:(UIViewAnimationOptionAllowUserInteraction) animations:^{
                        box.frame = CGRectMake(500, -200, 200,200);
                    } completion:^(BOOL finished) {
                       showing = NO;
                    }];

    }];    
}

}

Thank for your help and sorry for my English 🙂

Edit: more detail
I tried set start my box’s origin in screen (ex. 500,600), It still always response when tap at start point (500,600) even though my box move to another position.

Update:
I changed my way to move box outside screen by use NSTimer then it’s work!

[UIView animateWithDuration:0.5f delay:0.3f options:UIViewAnimationOptionAllowUserInteraction animations:^{

        box.frame = CGRectMake(500,200,200,200);

    } completion:^(BOOL finished) {
        isShowMenubar = YES;
        //use NSTimer instead of delay
        [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(hideBox) userInfo:nil repeats:NO];

    }]; 

and

-(void)hideBox {
[UIView animateWithDuration:0.5f delay:0.0f options:UIViewAnimationOptionAllowUserInteraction animations:^{
    box.frame = CGRectMake(500,-200,200,200);} completion:^(BOOL finished) {
        isShowMenubar = NO;
    }];
}
  • 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-05-31T21:23:06+00:00Added an answer on May 31, 2026 at 9:23 pm

    The reason why the box is not receiving touches has to do with how animation works. Your box is actually offscreen, but visually, it’s going through the animation.

    Even though you set the delay as 3.0, it still moves the box beforehand (due to the animation method still being called). So in your current code, if you tapped on the box at (500, -200) then it will receive the touch.

    To fix this, either use an NSTimer or Grand Central Dispatch to delay.

    NSTimer:

    [NSTimer scheduledTimerWithTimeInterval:3.0 target:self action:@selector(dismissBox) userInfo:nil repeats:NO];
    

    The problem with NSTimer is that you’ll have to put that animation code in a separate method.

    Grand Central Dispatch:

    double delayInSeconds = 3.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        [UIView animateWithDuration:0.5f animations:^{
            box.frame = CGRectMake(box.frame.origin.x, -200, 200,200);
    
        }completion:^(BOOL finished) {
            showing = NO;
        }];
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create an animated logo that serves as the splash screen for
I want to create a CCLayer with an animated tiled background from a larger
I want to create shadow under animated UIActivityIndicator to display that other ui elements
I want to create scroll behavior like what can be found here . If
I want to have a mesh that can be animated. I'm loading mesh from
I want to dismiss UIAlertView anywhere outside it with one tap. I want to
I want to create a menu such as on redhotchilipeppers.com. When you hover a
i have 2 activities, and i want to create an animated transition between the
I want create a excel with Apache POI in java and I must insert
i want create image animation , i have 50 images with png format now

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.