0

I have a UISplitViewController and I'm using it somewhat unconventionally. My detail view, dView, has a reference to my master view, mView.

I have a bit of code that is run every time the orientation changes. When it is in Portrait mode I set mView.view as a subview of dView. And when it is in Landscape mode, I don't.

It works fine, as long as I start in landscape mode. If I start there, I can rotate it as many times as I want and it does everything exactly as expected. BUT if I start in Portrait mode, mView doesn't show up at all (until I rotate it through a landscape mode).

I set this reference via IB. I figured that was as good a place as any to set the reference. But I also tried using UISplitViewDelegate methods to set it, but that didn't work at all (not even starting in landscape mode).

Any ideas?

RyanJM
  • 7,028
  • 8
  • 60
  • 90

1 Answers1

0

Your master view does not get instantiated when you launch in portrait view because it's not being displayed. You can test this with a simple NSLog() and you will see that it's (null), just before you assign the view controllers:

...
NSLog(@"master: %@", mView);
dView.masterReference = mView;
...

If you need your master view to show in portrait also, you could create your own SplitViewController instead of using UISplitViewController and "abusing" it. ;)

Pascal
  • 16,846
  • 4
  • 60
  • 69