开发者

iPad - UISplitViewController - unconventional use of UIViewController

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 rota开发者_StackOverflow中文版te 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?


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. ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜