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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:12:07+00:00 2026-06-08T18:12:07+00:00

I have a custom UIImageView class that I want to use to control my

  • 0

I have a custom UIImageView class that I want to use to control my UIImageViews.

Inside the custom init method I have the following regarding the UIAccelerometer:

    UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer];
    accelerometer.updateInterval = 0.5f;
    accelerometer.delegate = self;

My problem is that I have multiple instances of this class and the accelerometer only sends information to the last instance I create. I know the reason for this is because the delegate is being set to the last instance, so my question is:

Is there a way to set the delegate to all of these instances so all of them receive the “didAccelerate” call? If so then how would I go about it.

  • 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-08T18:12:08+00:00Added an answer on June 8, 2026 at 6:12 pm

    Disclaimer: the method you’re trying to use is deprecated. Use CMMotionManager instead. However:

    Set one delegate (it should be a separate class), then use NSNotificationCenter to distribute the information to the other listeners. Example:

    @interface SharedAccelerometerListener: NSObject <UIAccelerometerDelegate>
    @end
    
    @implementation SharedAccelerometerListener
    
    - (id)init
    {
        if ((self = [super init]))
        {
            [UIAccelerometer sharedAccelerometer].delegate = self;
            [UIAccelerometer sharedAccelerometer].updateInterval = 0.05f;
        }
    }
    
    - (void)accelerometer:(UIAccelerometer *)acc didAccelerate:(UIAcceleration *)acceleration
    {
        NSDictionary *info = [NSDictionary dictionaryWithObject:acceleration forKey:@"acceleration"];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"AccelerometerDidAccelerate" sender:nil userInfo:info];
    }
    
    @end
    

    Then in your listener class:

    id accelerationListener = [[SharedAccelerometerListener alloc] init];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didAccelerate:) name:@"AccelerometerDidAccelerate" object:nil];
    
    - (void)didAccelerate:(NSNotification *)notif
    {
        UIAcceleration *acc = [[notif userInfo] objectForKey:@"acceleration"];
        // do whatever you want with the acceleration
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom UIImageView class which I use to handle multi-touch events on
I have a custom UIImageView class that creates thumbnails (UIImageView) and each thumbnail has
I have a custom UITableViewCell with four UIImageView inside it. I want to detect
I have a custom UITabvleViewCell that has a UIImageView in it. I can set
I have a custom UITableView cell that has a UIImageView sized to the width
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have custom event that has several different subscribers who will all use the
I have a custom class, and that class has a UIButton instance variable. I
I have an UIImageView on my view. Certain parts of that image, I want
I have a custom cell that has an UIImageView in it that I do

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.