Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pushviewController/popviewController animation duration

Tags:

iphone

When I push or pop a UIViewController, how long does the animation takes to complete the slide animation. I have a view on the main window, which I need to slide in sync when a ViewController is pushed or popped.

Does anyone has any idea on the type and duration of animation that takes place when I push or pop a view.

Thanks in advance.

like image 915
Manish Ahuja Avatar asked Aug 18 '11 14:08

Manish Ahuja


People also ask

What is popViewController in Swift?

popViewController(animated:)Pops the top view controller from the navigation stack and updates the display.

How do I pop to present view controller in Swift?

You can do it by selecting the View Controller in Storyboard editor and clicking Editor -> Embed In -> Navigation Controller. Also make sure that you have your Storyboard Entry Point (the arrow that indicates which view controller is presented first) either pointing to Navigation Controller or before it.


2 Answers

Almost all animations in the iPhone are 0.3 seconds.

like image 193
rckoenes Avatar answered Oct 27 '22 07:10

rckoenes


In iOS 7 and later you can have exact value by setting the UINavigationController delegate and using the method:

- (void)navigationController:(UINavigationController *)navigationController
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated {
    NSTimeInterval duration = [viewController.transitionCoordinator transitionDuration];
}  

This is future proof method if the defult duration will ever change. At the moment it's value is 0.35 second.

like image 26
Tomasz Bąk Avatar answered Oct 27 '22 07:10

Tomasz Bąk