0

I am very much new to swift and ios so i need my doubts to be cleared for the below concept

I have created a view with a button having background image of back arrow and on button action i am going back to the previous controller which is the Login, is it safe to do it this way instead of using NavigationController??

@IBAction func onBackPressed(sender: AnyObject) {
    let aaa : Login =
    self.storyboard?.instantiateViewControllerWithIdentifier("Login")   
    as! Login

    self.presentViewController(aaa, animated: true, completion: nil)
}

Thanks

1
  • 1
    Use navigation controller and in navigation left bar button you can customize the back button that is the recommended approach Commented Oct 8, 2016 at 11:27

1 Answer 1

1

Navigation controller is best when you want to push to next View Controller.

(i.e) Navigation Controller ->View Controller ->View Controller[for Push].

So my suggestion is if you want to come back to previous view controller use Navigation Controller

When you want to present a new View Controller that time no need.

Sign up to request clarification or add additional context in comments.

2 Comments

thanx for replying ,what about this self.dismissViewControllerAnimated(true, completion: nil) on back pressed
this is when you present the view controller ,at the time this code needed for dismiss bro @narahari_arjun

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.