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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:04:29+00:00 2026-06-02T04:04:29+00:00

In my UIView, I’ve created a UIImageView called targetView where I have set it

  • 0

In my UIView, I’ve created a UIImageView called targetView where I have set it to a series of animations:

[UIView animateWithDuration:1.0
                 animations:^{self.targetView.center = CGPointMake(220,20);}
                 completion:^(BOOL finished){
                                             //another animation will begin;
                                            }];

I also created another UIImageView called shootView which will move to the target direction upon a finger swipe. Its movement is also implemented as an animation. At the end of its animation, detect the intersect with the targetView:

[UIView animateWithDuration:1.0
                 animations:^{
                 self.shootView.center = CGPointMake(destX, destY);}
                 completion:^(BOOL finished){
                            if (CGRectIntersectsRect(self.targetView.frame, self.shootView.frame)) {
                            //do something
                             }];

Now there is a problem: the intersect command only works fine if the targetView has reached the end point of the current animation and the shootView happens to be there. While the targetView is on the move somewhere in the middle of an animation, no intersect can be detected even if visually it is very obvious that the two frames are intersecting.

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

    This approach might be tricky since you can only get callbacks on the start and end of UIView animations. In your example the CGRectIntersectRect method is only being called after the animation has completed.

    One solution may be to use an NSTimer to animate the position of the shootview, and with each change of position do the collision detection. i.e

    [NSTimer timerWithTimeInterval: 0.03 target: self selector: @selector(timerTicked:) userInfo: nil repeats: YES];
    
    -(void) timerTicked: (NSTimer*) timer {
    
      // do move
      // check for colisions
      // optional invalidation of timer
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIView subclass that draws itself when -drawRect: is called. It only
[UIView animateWithDuration:1.0 animations:^(void) { im.transform = CGAffineTransformIdentity; } completion:^(BOOL finished) { [UIView animateWithDuration:1.0 delay:1.0
So I have a UIView object (called gauge) on the right hand side that
I have a UIView-based class called Icon. In there, I want to have code
I have created a UIView object using the contents of a NIB file like
myImageView : [UIView animateWithDuration:1.5 delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^{ } completion:^(BOOL finished) { } ]; How
I have a UIView called baseView and in that I have initWithFrame where I
I have a custom UIView that generates a set of subviews and display them
I have a UIView subclass called ToolbarView that sort of acts like a floating
I have a UIView subclass called Card that I move around on my board

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.