viewDidLoad
will not be called when navigating back, so you can set some sort of flag there and reset it in appropriate place (maybe viewDidAppear
?). As to if viewDidLoad
will be called every time you open it from SourceViewController
depends on your code - if you create a new instance every time, you should be fine.
As for an example :
class SampleViewController : UIViewController {
var isOpenedFromBackNavigation = false
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
if self.isOpenedFromBackNavigation {
// code that should be run if we navigated back here
}
self.isOpenedFromBackNavigation = true
}
}