0

I have an iOS app where two of my Tabs are following a same View with just a bit of change in the logic.Rather than that everything else is the same. But now the problem is occurring when i Rotate the app it misbehaves sometime. So i wanted to know If I should Use two different ViewControllers or two different ViewSources? because currently we have a common ViewSource and a master ViewController

Misbehaves means when i switch tab to other than these two and rotate then the master view selected rows changes after i visit the above mentioned tab

Say I visited Tab A and selected a row X and then I visited Tab B and selected row Y and then i visited Tab C and rotated the View So now when i visit Tab B again the selected row Y remains as it is while when I visit Tab A, indexpath of the row Y of the Tab B is selected in Tab A(and if the indexpath is not available then the app gets crashed)

If anyone could help Please. Thanks!

UserID0908
  • 98
  • 1
  • 15
  • As far i understand you have to implement the logic to get the selected index for specific view properly. Could help if you share you code with us. – Tanvir Nayem Mar 06 '18 at 05:42
  • indexpath which i'm talking about is the parameter in some of the override functions – UserID0908 Mar 06 '18 at 05:58

1 Answers1

1

I have been in somewhat similar situation the best and safest way to avoid this problem and the crash is to use another view controller with the help of container views. Container view will help you switch to view controllers on the tab click.

Moaz Khan
  • 1,272
  • 1
  • 13
  • 28