Search code examples
iosobjective-cuinavigationcontroller

What is the default time taken while navigating from for view to another view in IOS


I need a small clarification, I've 2 UIViewControllers on pressing on a button from one viewcontroller,I need to navigate to other. But I need to know what is the time taken internally by this UIViewContoller, when we call some this like this.

MyViewController *ins = [[MyViewController alloc]init];
[self.navigationController pushViewController:ins animated:YES];

We all know if that "animated" if "YES" then it will take some time , I need that time or help me in calculating that time.


Solution

  • Not sure why have this question, but I did a small demo to verify this -

    Without animation -

    Printed timeframe before push - 05/03/2017 11:07:35.7480

    Printed timeframe after push - 05/03/2017 11:07:35.7550

    With animation -

    Printed timeframe before push - 05/03/2017 11:09:42.9680

    Printed timeframe after push - 05/03/2017 11:09:42.9760

    @IBAction func buttonTapped(_ sender: Any) {
        let bVC = AHBViewController()
        bVC.view.backgroundColor = UIColor.blue
        let startDate = Date()
        print(dateFormatter.string(from: startDate))
        self.navigationController?.pushViewController(bVC, animated: true)
        let endDate = Date()
        print(dateFormatter.string(from: endDate))
    
    }