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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:37:31+00:00 2026-05-27T07:37:31+00:00

Im trying to write a simple program that takes 5 images and allows you

  • 0

Im trying to write a simple program that takes 5 images and allows you to drag them from the bottom of the screen and snap them on to 5 other images on the top in any order you like. I have subclassed the UIImageView with a new class and added the touches began, touches moved and touches ended. Then on my main viewcontroller I place the images and set their class to be the new subclass I created. The movement works great in fact I am NSLogging the coordinates in the custom class.

Problem is I’m trying to figure out how to get that CGpoint info from the touches end out of the custom class and get it to call a function in my main view controller that has the image objects so i can test whether or not the image is over another image. and move it to be centered on the image its over (snap onto it).

here is the code in my custom class m file. MY view controller is basically empty with a xib file with 10 image views 5 of which are set to this class and 5 are normal image views..

#import "MoveImage.h"


CGPoint EndPoint;

@implementation MoveImage


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    startPoint = [[touches anyObject] locationInView:self];
    }

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    CGPoint newPoint = [[touches anyObject] locationInView:self.superview];

    newPoint.x -= startPoint.x; 
    newPoint.y -= startPoint.y;
    CGRect frm = [self frame];
    frm.origin = newPoint;
    [self setFrame:frm]; 
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *end = [[event allTouches] anyObject];
    EndPoint = [end locationInView:self];
    NSLog(@"end ponts x : %f y : %f", EndPoint.x, EndPoint.y);

} 

@end
  • 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-27T07:37:32+00:00Added an answer on May 27, 2026 at 7:37 am

    You could write a MoveImageDelegate protocol which your app controller would then implement. This protocol would have methods that your MoveImage class can call to get its information.

    In your header file ( if you don’t know how to write a protocol )

    @protocol MoveImageDelegate <TypeOfObjectsThatCanImplementIt> // usually NSObject
    // methods
    @end
    

    then you can declare an instance variable of type id, but still have the compiler recognize that that variable responds to your delegate selectors ( so you can code without those annoying warnings ).
    Something like:

    @interface MoveImage : UIImageView
    {
     id <MoveImageDelegate> _delegate;
    }
    
    @property (assign) id <MoveImageDelegate> delegate;
    

    Lastly:

    @implementation MoveImage
    
    @synthesize delegate = _delegate;
    

    And your delegate is complete.

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

Sidebar

Related Questions

I am trying to write a simple Ruby program that I will run from
I'm trying to write a program that takes input of - hexadecimals, octals, and
I am trying to write a simple program that lets me overlay a dot
I'm trying to write a simple program that will compare the files in separate
I am trying to write a c++ program that would read key frames from
I'm trying to write a simple high-low program that will output like this: $
I'm trying to write a very simple program in C++ that finds the modulus
I am trying to write a simple program that writes to a file that
it's a week that I'm trying to write a program that download correctly from
I'm trying to write a simple C++ program that uses Berkeley DB for storage.

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.