7

アプリケーションでスクリーンショットを撮る方法を実装しようとしています。UINavigationBar の先端を上にスライドさせたい (スクリーンショットを撮る) と、UINavigationBar を簡単に下にスライドさせることができます。この方法では最初のアニメーションが終了する時間がないため、アプリがコード行間で数秒間待機/保持する必要があります。

[self.navigationController setNavigationBarHidden:YES animated:YES ];
[self.navigationController setNavigationBarHidden:NO animated:YES];

それで、ボタンをアニメーション化するときのように、実行を遅らせる方法はありますか:

[UIView animateWithDuration:0.5 delay:3 options:UIViewAnimationOptionCurveEaseOut animations:^{self.myButton.frame = someButtonFrane;} completion:nil];

よろしく

4

3 に答える 3

11

以下を使用できます。

double delayInSeconds = 2.0; // number of seconds to wait
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    /***********************
     * Your code goes here *
     ***********************/
});    
于 2013-09-29T15:48:19.893 に答える
3

以下を使用できます。

[self performSelector:@selector(hideShowBarButton) withObject:nil afterDelay:1.0];

そしてもちろん:

- (void) hideShowBarButton{
    if (self.navigationController.navigationBarHidden)
        [self.navigationController setNavigationBarHidden:NO animated:YES ];
    else
        [self.navigationController setNavigationBarHidden:YES animated:YES ];
}
于 2013-09-29T15:42:35.337 に答える
0

setNavigationBarHiddenの完了に対するコールバックはないようですが、UINavigationControllerHideShowBarDuration数秒かかります。だからNSTimerそれを遅らせるために a を使うだけです:

[NSTimer scheduledTimerWithTimeInterval:UINavigationControllerHideShowBarDuration target:self selector:@selector(myFunction:) userInfo:nil repeats:NO];

フェイルセーフとして遅延に少量を追加することをお勧めします。

[NSTimer scheduledTimerWithTimeInterval:UINavigationControllerHideShowBarDuration+0.05 target:self selector:@selector(myFunction:) userInfo:nil repeats:NO];

この関連する質問も参照してください: UINavigationControoller - setNavigationBarHidden:animated: How to sync other animations

于 2013-09-29T15:42:57.150 に答える