views:

48

answers:

1

I am calling a function in Accelerometer delegate method like this

This is in ViewControllerX.m

-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
   [self methodX];
}

i am also calling another function in interface method like this

This method is in ViewControllerY

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

  [object methodY];
  //Here "object" is ViewControllerX.m 's Object,

} 

The problem is, when i shake my iPhone

methodY is calling instead of, methodX.

can any one tell me how to handle this?

+1  A: 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

should simply return a BOOL value indicating whether or not the interfaceOrientation is supported or not. From the UIViewController documentation:

Your implementation of this method should simply return YES or NO based on the value in the interfaceOrientation parameter. Do not attempt to get the value of the interfaceOrientation property or check the orientation value reported by the UIDevice class. Your view controller is either capable of supporting a given orientation or it is not.

In my experience, it is not a good idea to any extensive processing inside this method.

TomH