siwft メモリーリークエラー対応 画面遷移

問題

f:id:happy_teeth_ago:20210406124447p:plain

問題のコード

  
    @IBAction func logSettingButtonTapped(_ sender: Any) {
        let storyboard = UIStoryboard(name: "LogSetting", bundle: nil)
        let nextVC = storyboard.instantiateInitialViewController()!
        nextVC.modalPresentationStyle = .fullScreen
        present(nextVC, animated: true, completion: nil)
    }

画面遷移はする。しかし、どんどんインスタンスを生成してしまう

fix

  @IBAction func logSettingButtonTapped(_ sender: Any) {
        tabBarController?.selectedIndex = 0
    }

この記事が参考になる

https://stackoverflow.com/questions/38215738/navigation-controller-with-tab-bar-controller