2013-09-29 6 views
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]; 

संबंध

उत्तर

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 ]; 
} 
0

जबकि वहाँ setNavigationBarHidden के पूरा करने के लिए एक कॉलबैक होने के लिए प्रकट नहीं होता है, यह UINavigationControllerHideShowBarDuration सेकंड का समय लगेगा। तो बस इसे देरी करने के लिए एक NSTimer का उपयोग करें: एक असफल-सुरक्षित

[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

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 * 
    ***********************/ 
});  
संबंधित मुद्दे

 संबंधित मुद्दे