为什么我的ViewController在每次转到它时都会重新加载?

时间:2015-11-28 19:34:50

标签: ios swift

HomeViewController的标题如下所示:

private let sharedGameBoard = HomeViewController()

class HomeViewController: UIViewController, CLLocationManagerDelegate, UITextFieldDelegate {

class var sharedInstance: HomeViewController {

    return self.sharedInstance

}

我将HomeViewController嵌入UINavigationController。要导航到MultipleChoiceViewController我致电:

var multipleChoiceVC: MultipleChoiceViewController = self.storyboard?.instantiateViewControllerWithIdentifier("multipleChoiceViewController") as! MultipleChoiceViewController

self.navigationController?.pushViewController(multipleChoiceVC, animated: true)

要从MultipleChoiceViewController返回,我会在我的show文件中调用与main.storyboard文件中的滑动手势相关联的MultipleChoiceViewController segue。

每次从HomeViewController导航到HomeViewController时,viewDidLoad都会重新加载。我如何防止这种情况发生。就像在许多应用程序中看到的那样,我希望能够在没有每次加载家庭控制器的情况下从详细视图导航回家庭控制器。

我的加载函数在l = StreamListener() streamer = tweepy.Stream(auth=auth, listener=l) streamer.userstream(_with='followings') 中调用,但我有一个全局bool变量,指示是否应该调用加载函数。

我花了很多时间试图理解单身人士,推/显示segues和导航堆栈,试图减轻可能是一件非常简单的事情。有什么方法可以实现这个?

0 个答案:

没有答案