アニメーションを開始する揺れを検出し、アニメーションが終了するとアニメーションを停止します。動作する場合もありますが、シェイクが終了したことに気付かない場合もあるため、motionEndedメソッドを呼び出すことはありません。他の誰かがこの問題を抱えていましたか?ソリューション?
-(BOOL)canBecomeFirstResponder {
return YES;
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:NO];
[self becomeFirstResponder];
}
-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:NO];
}
-(void)viewDidDisappear:(BOOL)animated {
[self resignFirstResponder];
[super viewDidDisappear:NO];
}
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.type == UIEventSubtypeMotionShake )
{
NSLog(@"1");
[img startAnimating];
}
}
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.type == UIEventSubtypeMotionShake )
{
NSLog(@"3");
[img stopAnimating];
}
}