ナビゲーションコントローラを使用せずにダブルタップしてUIViewのシングルタップでナビゲーションバーを非表示にする方法はありますか?また、隠れて見せているアニメーションもありますか?UIviewをダブルクリックするとナビゲーションバーが表示されない
ありがとうございます。
ナビゲーションコントローラを使用せずにダブルタップしてUIViewのシングルタップでナビゲーションバーを非表示にする方法はありますか?また、隠れて見せているアニメーションもありますか?UIviewをダブルクリックするとナビゲーションバーが表示されない
ありがとうございます。
UITapGestureRecognizer* tapGesture =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(your_selector)];
tapGesture.numberOfTapsRequired = 2;
[self.view addGestureRecognizer:tapGesture];
[tapGesture release];
:
-(void)your_selector{
[UIView animateWithDuration:0.5
animations:^{
bar.frame = CGRectOffset(bar.frame, 0, bar.bounds.size.height*bar.frame.origin.y<0?-1:1);
}];
}
あなたが唯一持っている。この実装では、二重バーのステータスを反転させるタッチイベントです。 残念ながら、一度にシングルタッチとダブルタッチジェスチャーの実装が容易ではありません。より多くの人間の行動とあなたのための簡単 - ダブルタッチのイベントでのみ動作します。
は
[UIView beginAnimations:@"Hide bar animation" context:NULL];
[UIView setAnimationDuration:0.5];
navigationBar.alpha = 0.0;
[UIView commitAnimations];
for showing
[UIView beginAnimations:@"Show bar animation" context:NULL];
[UIView setAnimationDuration:0.5];
navigationBar.alpha = 1.0;
[UIView commitAnimations];
を隠すためにこれをしようとしたがUINavigationControllerと、それはあまりにも簡単です...あなたのセレクタで
バーのアニメーションを非表示にしてバーのナビゲーションを表示することはどういう意味ですか? viewwillappearとviewwilldisappearでこのコードを試しても大丈夫ですか? – Priya
は両方とも、アニメーションのアプリケーション提供識別子です。あなたはそのための任意の文字列を設定することができます –
あなたはナビゲーションコントローラなしUINavigationBar
を持つことができます。
navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 40.0f)];
[navBar setDelegate:self];
[mainView addSubview:navBar];
UITapGestureRecognizer
は、単一または複数のタップを探しUIGestureRecognizer
の具象サブクラスである:ここでは
UITapGestureRecognizer *doubleTap =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideNavBar:)];
[doubleTap setNumberOfTapsRequired:2];
[YOURVIEW addGestureRecognizer:doubleTap];
UITapGestureRecognizer *singleTap =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showNavBar:)];
[singleTap setNumberOfTapsRequired:1];
[YOURVIEW addGestureRecognizer:singleTap];
ですナビゲーションバーを表示または非表示にするメソッド:
- (void)hideNavBar:(id)sender
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0f]; //Animation duration in seconds
navBar.alpha = 0.0f;
[UIView commitAnimations];
}
- (void)showNavBar:(id)sender
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0f]; //Animation duration in seconds
navBar.alpha = 1.0f;
[UIView commitAnimations];
}
しかし、それは動作していません... – Priya
何がうまくいかない?セレクタは呼び出されないか、移動されません。 – OdNairy
それは隠れていません。 – Priya