Question

I have an "interesting" issue with the UIAccelerometer in an app for the iPad.

In my UIViewController I have a method that activates the Accelerometer. This is how it looks like:

-(void)startAcc{

UIAccelerometer *gForce = [UIAccelerometer sharedAccelerometer];
gForce.delegate = self;
gForce.updateInterval = kUpdateInterval;
}

In my viewWillAppear I call this method to activate the Accelerometer, and it works just fine. I recieve accelerations and use it to move a view on screen.

On user input I then load another view (UIView) that need to use the accelerometer. So I stop the accelerometer in my UIViewController with this code:

[UIAccelerometer sharedAccelerometer].delegate = nil;

I then load the UIView and activates the accelerometer there in the same way. All works just fine.

My issue begins when I want to close the UIView and start the accelerometer in the UIViewController again. I stop it in the UIView and call the startAcc method in my UIViewController from the UIView. The method executes, but I receive no accelerations :-(

Same method, but different results.

Can anyone guide me to what I am missing here?

Thanks

Was it helpful?

Solution

Solved it. By putting [self resignFirstResponder]; after I call the startAcc method from the subview it works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top