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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:23:50+00:00 2026-05-23T12:23:50+00:00

How do I check for collisions between two UIImageViews using a method not in

  • 0

How do I check for collisions between two UIImageViews using a method not in the ViewController class?

For example:

This method bellow is in the rock class but glass UIImageView is in the ViewController.

if(CGRectIntersectsRect(rock.frame, glass.frame))
{
//do stuff
}

It complains that glass isn’t declared. So how do I refer to the glass UIImageView in the ViewController if I’m calling the collision method from the rock class???
I’m not sure exactly how to get classes to ‘talk’ to each other in general – it’s a concept I don’t quite understand so a small example would be much appreciated! Or if somebody could point out a good place to learn this concept that would help a lot.
Thanks.

  • 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-23T12:23:51+00:00Added an answer on May 23, 2026 at 12:23 pm

    The solution was simple in the end. I just didn’t understand the concept of getter and setter methods.

    So the answer was to make a method in the ‘glass’ object like so:

    -(BOOL)collidesWithRect:(CGRect)rect
    {
       return (CGRectIntersectsRect(self.frame, rect));
    }
    

    And then call it from the ‘rock’ object:

    if([rock collidesWithRect:glass.frame])
    {
        //collision code
    }
    

    Which returns true when the two rectangles intersect.

    I’m surprised I didn’t get any replies for this as it was simple solution in the end. Perhaps I didn’t explain myself properly? Hope I explained the solution correctly. If not then please feel free to correct me. We wouldn’t want the blind leading the blind now would we!!!

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

Sidebar

Related Questions

Check out this test: [TestFixture] public class Quick_test { [Test] public void Test() {
check this out: template <class T> class Test: public T { public: void TestFunc()
check this example: > a = matrix(1:9, nrow = 3, ncol = 3, dimnames
First check out this code. I seems like it should work for me, but
If I have a sprite, how would I check collision between two points? For
I'm using Chipmunk 5 for iPhone, with Cocos2D. Upon collision between two specific objects
I am trying to check collisions between a QPolygon and a QRect by turning
I'm struggling to find a rock solid solution to detecting collisions between a circle
It seems to me that tmpfs is not re-using inode numbers, but instead creates
i use boundingBox to check collision, it's fine for touches, but not at all

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.