我想添加一个启动按钮来启动加速度计,如何设置 IBAction 来做到这一点,在我使用的代码中:
-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
x.text = [NSString stringWithFormat:@"X is: %f", acceleration.x];
y.text = [NSString stringWithFormat:@"Y is: %f", acceleration.y];
z.text = [NSString stringWithFormat:@"Z is: %f", acceleration.z];
NSLog (@"Y = @%f", y.text);
}
-(IBAction)startPedometerPressed {
[startButton accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration];
}
由于未声明的标识符“加速度计”,这将返回错误。
我确定我调用该方法的方式有问题,但不确定是什么!