Search code examples
iosnavigationstoryboardseguecustom-transition

iOS 7 - Maintain view controller instance in Storyboard segue


I have an interactive custom view controller transition based on a storyboard segue (push).

The target view controller takes some time to be loaded as it contains a table with a lot of data; moreover when I leave this vc and come back, I need the table to maintain its content offset and not to start each time from the first row.

In order to achieve these two points I need the target vc to be a kind of singleton, and not to be deallocated/reallocated every time.

Any suggestion?

Thanks, DAN


Solution

  • Don't use a segue -- they always instantiate new view controllers. Create a property for the destination view controller in the controller that initiates the transition, and only instantiate it the first time you go to it. Push the new controller in code.