私のアプリにはいくつかのアニメーションがあります。たとえば、メインメニューにボタンがあり、それをクリックするとアニメーションが開始され(場所の移動など)、アニメーションの最後に別のページに移動します。必要なのは、アニメーション中のユーザー操作を無効にすることです。アニメーション中にボタンの始点を押すと、ナビゲートされるはずのページが2回開かれるためです。要約すると、アニメーション中にユーザーとの対話を一切許可しないと、問題は解決します。どうやってやるの?
9665 次
8 に答える
21
アニメーションの前:
self.view.userInteractionEnabled = NO;
アニメーション完了ブロック:
self.view.userInteractionEnabled = YES;
于 2012-09-06T15:08:59.893 に答える
18
これは役立つかもしれません:
// for ignoring event
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
コードは次のようになります。
[UIView animateWithDuration:1.0 animations:^{
//some animation
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
}
completion:^(BOOL done){
if (done){
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
}
}
];
于 2013-06-19T07:13:15.800 に答える
6
setUserInteractionEnabled
シンプルで、アニメーションが開始する前にに設定できNO
、アニメーション完了ハンドラーでに戻すことができYES
ます。
[myObject setUserInteractionEnabled:NO];
[UIView animateWithDuration:1.0 animations:^{
[myObject setTransform:CGAffineTransformMakeTranslation(100, 100)];//some animation
}completion:^(BOOL done){
if (done){
[myObject setUserInteractionEnabled:YES];
}
}];
于 2012-09-06T15:07:46.517 に答える
5
完了ブロックをハックする必要はありません。これを正確に実行するアニメーションオプションがあります。
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
// animations here
}
completion:nil];
を設定した場合UIViewAnimationOptionAllowUserInteraction
、ユーザーの操作は許可されます。
于 2012-09-06T15:15:20.847 に答える
2
yourView.userInteractionEnabled = NO;
[UIView animateWithDuration:1 animations:^
{
//animations here
}
completion:^(BOOL finished)
{
yourView.userInteractionEnabled = YES;
}];
于 2012-09-06T15:08:32.257 に答える
2
ビューでタッチイベントを無効にするには、
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
ビューでタッチイベントを有効にするには
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
于 2013-08-30T10:19:20.470 に答える
1
ButtonのuserIntrectionを無効にします。
Btn.userInteractionEnabled = NO;
于 2012-09-06T15:09:16.610 に答える
0
ページを開くアイコンが付いたViewControllerがありました。ユーザーがicon1とicon2をすばやくタップすると、2つのページが開きます。
タップイベントの開始までにこの2行があったことを防ぐために、これにより、何が起こっても、endIgnoringが呼び出されることを確認します。
-(void) on_image_tap:(UITapGestureRecognizer * ) tapGesture
{
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[[UIApplication sharedApplication] performSelector:@selector(endIgnoringInteractionEvents) withObject:nil afterDelay:0.5f];
于 2015-08-21T11:46:56.063 に答える