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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:41:01+00:00 2026-06-15T00:41:01+00:00

I need to handle touch on my object when it move across my screen.

  • 0

I need to handle touch on my object when it move across my screen. When touchesBegan called I need to hide my object.

this is my code in UIViewController:

- (void)win {
    for (NSInteger i = 1; i <= 6; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"rocket_%d.png", i]]];
        imageView.tag = 1000;
        CGSize size = imageView.image.size;
        [imageView setFrame:CGRectMake(200 + (i * 60), 500, size.width, size.height)];
        [self.view addSubview:imageView];
        [rockets addObject:imageView];
        [imageView setUserInteractionEnabled:YES];
    }
    [self startRockets];
}

- (void)startRockets {

    CGFloat timeInterval = 1.0;
    for (UIImageView *imageView in rockets)  {
        [UIView animateWithDuration:5.0 delay:timeInterval options:UIViewAnimationOptionAllowUserInteraction animations:^{
            [imageView setFrame:CGRectMake(imageView.frame.origin.x, 0, imageView.frame.size.width, imageView.frame.size.height)];
        } completion:nil];
        timeInterval += 1.0;
    }


}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint touchLocation = [touch locationInView:self.view];
    NSArray *views = [self.view subviews];
    for (UIView *v in views) {
        if (v.tag == 1000) {
            if (CGRectContainsPoint(v.frame, touchLocation) == YES) {
                [v setHidden:YES];
            }
        }
    }
}
  • 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-15T00:41:02+00:00Added an answer on June 15, 2026 at 12:41 am

    Maybe you are missing the AllowAnimatedContent. Try changing your

    UIViewAnimationOptionAllowUserInteraction

    to

    UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionAllowAnimatedContent


    …another way might be to use UITapGestureRecognizer :

    - (void)createViews {
        rockets = [[NSMutableArray alloc] init];
        for (NSInteger i = 1; i <= 6; i++) {
            UIView *view = [UIView new];
            view.backgroundColor = [UIColor redColor];
            view.frame = CGRectMake((i * 60), 100, 50, 50);
    
            UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(rocketTouched:)];
            [view addGestureRecognizer:tap];
    
            [self.view addSubview:view];
            [rockets addObject:view];
        }
        [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(moveViews) userInfo:nil repeats:YES];
    }
    - (void)moveViews {
        for (UIView * view in rockets)  {
            [UIView animateWithDuration:5.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionAllowAnimatedContent animations:^{
                view.frame = CGRectMake(view.frame.origin.x -10, 0, view.frame.size.width, view.frame.size.height);
            } completion:nil];
        }
    }
    - (void)rocketTouched:(UITapGestureRecognizer*)tap {
        tap.view.hidden = YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in urgent need of an Objective-C/Cocoa/Cocoa Touch framework to handle simple charting; pie
I am developing an Android application and I need to handle various touch events.
I am developing for a touch screen and need to detect touch events to
In my Sencha Touch 2 application I need to handle redirection events on my
I need to handle events of two different types but I'm running into the
I need to handle strings in my php script using regular expressions. But there
For a project I need to handle audio in an iPhone app quite special
I'm writing a batch (.bat) script and I need to handle the case in
I have a problem with NCurses ... i need to handle all keys like
I'm using IIS7 and ASP.NET. Basically building a simple CMS and need to handle

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.