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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:43:40+00:00 2026-05-18T03:43:40+00:00

Actually i want to apply a loop on accelerometer, means i want to start

  • 0

Actually i want to apply a loop on accelerometer, means i want to start a accelerometer on behalf of loop. if i want to start loop one then want to perform accelerometer reading one time. if loop will run twice then want to run accelerometer twice. But it not happens. What should i do to control accelerometer.

Have a quick look on code

in viewdidload

for (int i=0; i<3; i++) 

    {
        NSLog(@"Hellooooooooo",i);
        [[UIAccelerometer sharedAccelerometer] setDelegate:self];
    }

and in accelerometer didAccelerate

{
        float xx = -[acceleration x]; 
    float yy = [acceleration y]; 

} 

I don’t know what is going wrong ?

help me if u have some idea about it.

thanks in advance for any help.

  • 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-18T03:43:40+00:00Added an answer on May 18, 2026 at 3:43 am

    I have solved this issue .
    Just apply a int count variable and assign the count value initialize. Take the value from the user, according to your needs and check out the condition in the accelerometer delegate. Increase the count variable every time and stop the accelerometer at specific count which u want.

    - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:
                         (UIAcceleration *)acceleration 
    { 
        // Get the current device angle
    
            float xx = -[acceleration x];
    
           float yy = [acceleration y]; 
    
           if(count <= userChoice)
           {
               if(deviceOrientation != UIInterfaceOrientationPortraitUpsideDown)
               {
                   // here we will start NStimer to calcualte actual time
    
                      NSLog(@"Count Before = %d",count);
    
                      alert.hidden=TRUE;
    
                      deviceOrientation = UIInterfaceOrientationPortraitUpsideDown;
    
                      [self startTimer];
    
                      count++;
    
                      NSLog(@"Count after = %d",count);
              }
          }
    
     if (count <= 1) 
     {
         count++;
    
     }
    
     else 
     {
          UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"Stop" message:@"Your rounds are ended." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    
          [alert show];
    
          [alert release];
    
       }
    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to set the database connection at run time for my Play project.
I make a fix in one branch and want to apply it to another
My script defines one main parser and multiple subparsers. I want to apply the
How do I enumerate the properties of a JavaScript object? I actually want to
I got a question ;) Actually I want to use core-data in different threads.
Somehow my master and my origin/master branch have diverged. I actually don't want them
I want to know what actually happens when you annotate a method with @Transactional
Actually it's a lot easier to show you what I want to achieve instead
Actually, I want to integrate spring javadoc with my netbeans IDE. Spring website only
There are actually 2 question i want to cover in this topic. 1) Is

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.