-1

I have a simple flash card app I wrote for a friend of mine. I'm a hobby-est at best. It's essentially Tinder that you can flip the card over for a dead language. Everything has been working great up until the iOS 13 update with how Apple redid the Storyboards for flexibility.

My problem is my elegant solution to save userdefaults when exiting a view is no longer being called. This "carddeck" view controller is called when a button on another screen is pressed. To exit this same view controller before you would press a button that was tied to an "action segue - show" (not @IBAction) that would bring the view back to the "mainview" view controller. I tried the same action segue with "present modally." but no dice.

class CardDeckViewController: UIViewController {

override func viewDidLoad() {
        super.viewDidLoad()
        // called!
}

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(true)
        // called!
}

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(true)
        // not called when "return" on this screen is pressed; 
        // however, it still returns to the main screen it just doesn't save the user's score
}

Any help would be appreciated. My hope is there is an easier fix than redoing the entire storyboard. I see about UIModalPresentFullScreen. I'm no Swift guru so at this point I thought I would reach out to the pros. Hopefully this is too time consuming of a fix. Luckily I think the other views are not affected by this other than one more.

Thanks for reading!

2 Answers2

-1

A couple of things you might try:

  1. It sounds like you're presenting the "main view" view controller again. Hard to tell without seeing your code but I think you should probably be dismissing "CardDeck" view controller in order to get back to your "main view" view controller.

  2. Have a look at UIAdaptivePresentationControllerDelegate. This stackoverflow post covers the change and iOS 13 solution.

  3. I had some similar issues with iOS 12 view controller lifecycle behavior being changed in iOS 13.

I suggest considering NotificationCenter if nothing else works. You broadcast from your current view controller and someone like your AppDelegate can receive the message and act on this. It's not always the best tool for the job but it can help in certain situations.

  1. Not related to your question but your calls to super super.viewWillAppear(true) should probably be super.viewWillAppear(animated) so you're not disregarding the method argument.
Chris
  • 29
  • 4
  • Thanks man! Yes, the "action segue" by pressing the RETURN button shows Main View. Main view is defined as: class MainViewController: UIViewController {...} I'll take a look at the SO link and give that a go. I want the design to last as far into the future as possible. This is an educational app that the money (all $200/yr woot woot!) goes to the author. I want to maintain it as little as possible so I'll try and do it right. – lil_matthew Sep 24 '20 at 20:30
  • I saw this link: https://stackoverflow.com/questions/56435510/presenting-modal-in-ios-13-fullscreen I'm not sure how to splice this code snippet into my project. All my View Controllers are full screen. The program is just a series of ui controllers going back and forth. All declared UIViewController(). Would the code snippet go in my appdelagate? – lil_matthew Sep 24 '20 at 20:52
  • It looks like you've already sorted this out but you'd use that code snippet in any presenting view controller when you'd like the presented view controller to appear full screen. – Chris Sep 25 '20 at 03:22
-1

The answer was at the bottom of this question:

Presenting modal in iOS 13 fullscreen

I just had to redefine the storyboard UI property from Automatic to Full Screen.