I'm making an app that uses motionBegan to call a function. However it just call my function once when I shake my phone, then once more if I stop and shake it again. While I want to have the func active as long as I'm shaking the phone. Any ideas what I should do ?
问问题
53 次
1 回答
0
尝试这个:
迅速:
override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
if motion == .motionShake {
print("Device Shaked")
}
}
Objective-C
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.type == UIEventSubtypeMotionShake)
{
NSLog(@"Device Shaked") ;
}
}
于 2019-11-19T11:01:37.160 回答