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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:57:13+00:00 2026-05-12T23:57:13+00:00

I have an imageView in the view. It moves even if the iphone is

  • 0

I have an imageView in the view. It moves even if the iphone is still for some time. Why is it so ? Also the image does not respond quickly to the movement of the iphone.

Here is my code written for this:

I have also set the updateInterval and delegate for the accelerometer.

#define kVelocityMultiplier 1000;



-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
    if(currentPoint.x < 0)
    {
        currentPoint.x=0;
        ballXVelocity=0;
    }

    if(currentPoint.x > 480-sliderWidth)
    {
        currentPoint.x=480-sliderWidth;
        ballXVelocity=0;
    }
    static NSDate *lastDrawTime;
    if(currentPoint.x<=480-sliderWidth&&currentPoint.x>=0)
    {

        if(lastDrawTime!=nil)
        {
            NSTimeInterval secondsSinceLastDraw=-([lastDrawTime timeIntervalSinceNow]);
            ballXVelocity = ballXVelocity + -acceleration.y*secondsSinceLastDraw;

            CGFloat xAcceleration=secondsSinceLastDraw * ballXVelocity * kVelocityMultiplier;

            currentPoint = CGPointMake(currentPoint.x + xAcceleration, 266);
        }
        slider.frame=CGRectMake(currentPoint.x, currentPoint.y, sliderWidth, 10);
    }
    [lastDrawTime release];
    lastDrawTime=[[NSDate alloc]init];
}

Can anyone help me out please ?

  • 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-12T23:57:13+00:00Added an answer on May 12, 2026 at 11:57 pm

    I notice a couple of things in the code

    • The two first if statements to have the position within a certain range should be done just before the slider position is set, otherwise it can happen that the image will be set outside the preferred range.

    • ballXVelocity is calculated as normalized from the acceleration.y value times the delta time. Maybe you should look into multiplying that factor instead of doing the kVelocityMultiplier on the next line.

    • As the accelerometer is very sensitive and it is hard to make perfect fit on the circuitboard one never get perfect value. Instead one should try to have some calibration stage and perhaps use only a valid range similar the two first if statements.

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

Sidebar

Related Questions

I have a ImageView and draw some things on that view. Now I want
In an iPhone application I'm developing I have a Image View that displays eyes
I have a problem which bothers me for some time. I have an imageView
In my view i have ImageView.If i click ,it should open nextview. Please help
I have imageView with some frame imageView.frame = CGRectMake(0,0, 100, 100); imageView.contentMode = UIViewContentModeScaleAspectFit;
I have a UIScrollView whose content size is 1200x480. I have some image views
I am trying to drag an image view. I have got little bit of
I Have 1 image view and 4 Edit texts ,On runtime i am setting
I have table view cells with cell image and text label and detailed label.
I have an large image I have put in an image view. the image

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.