-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{ if(motion==UIEventSubtypeMotionShake)
{
代码A
}
}
-(BOOL)canBecomeFirstResponder{ return YES;
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
-(void)viewWillDisappear:(BOOL)animated
{
[self resignFirstResponder];
[super viewWillDisappear:animated];
}
1 回答
鸿蒙传说
TA贡献1865条经验 获得超7个赞
如果你要响应多次,建议使用UIAccelerometer
- (void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { if (fabsf(acceleration.x) > 1.0 || fabsf(acceleration.y) > 1.0 || fabsf(acceleration.z) > 1.0) { 代码A } }
- 1 回答
- 0 关注
- 115 浏览
添加回答
举报
0/150
提交
取消