This is my app design concept:
On launch -
- A table view opens with a + button in the nav bar (this works fine)
- When the + button is tapped a new table view is created programmatically and opens with a Done button in its nav bar (this works correctly)
- User enters data into the table view rows then taps the Done button when finished (this is my problem)
My code for returning the user back to the main table view controller does not function as I would like. Here is my button code:
func doneButtonPressed(sender: UIButton!) {
/
/
/
let message = "You just pressed the Done button."
let alert = UIAlertController(
title: "Thank you",
message: message,
preferredStyle: .Alert)
let action = UIAlertAction(
title: "Goodbye",
style: .Default,
handler: nil)
alert.addAction(action)
*/
/
/
/
/
/func interactionControllerForDismissal(animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
return mainview()
}
*/
/
/
let viewController:UIViewController = UIViewController()
self.presentViewController(viewController, animated: true, completion: nil)
}Looking at the code -
If line 18 is active the alert will pop up. The alert is just test code to make certain that my button is actually working and it is.
If both line 18 and 20 are active, the alert will pop up momentarilly then be dismissed. Line 20 causes the pop up to close. The code on line 20 only closes the alert view and that is not what I want to happen. I would like for the user to be returned to the viewController.swift that she came from.
I also tried the code on lines on 32-33 and this simply took the user to a black view. I am sure this happened because this is a blank view and not the ViewController.swift controller that I wanted.
For the sake of clarity: When user taps the + button in the opening table view, this results in a new view, table view, nav bar and Done button that are all created programmatically. There are no segues involved. Much of the code I found in my reseach made reference to segues and that is not what I have.
If someone could point me in the right direction I would be most appreciative.
Thank you!