[iOS] Is there a function to finish a UIviewcontroller like in android?

Not quite. In iOS land you have to more explicitly call viewController.dismissViewControllerAnimated(true, completion: nil) if your view controller is a modal or one of the various dismissal methods on UINavigationController if your viewController was pushed on to the screen.

In Swift 3 this function is:

viewController.dismiss(animated: true)

 


If you want to go back to the previous view controller

_ = navigationController?.popViewController(animated: true)

If you want to go back to the root view controller

_ = navigationController?.popToRootViewController(animated: true)

 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *