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 ?
Asked
Active
Viewed 70 times
1 Answers
0
Try this:
Swift:
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") ;
}
}

Nick
- 875
- 6
- 20