Sometimes willHideViewController from UISplitViewControllerDelegate is not called

我与影子孤独终老i 提交于 2019-12-05 12:18:30
CracyD

Where do you set the splitViewControllers delegate? Perhaps you can set the delegate when you load the tab. It sounds like you set it only when you have rotated once?

Otherwise, see this example

Here they have the TableViewController be the delegate of the splitviewcontroller. Perhaps you could do the same with the TabBarController?

I've concluded that this can't be done in any way that I consider 'sufficiently' legitimate. It's possible to get frustratingly close, but the issue of having the willShow..., willHide disseminated to the split view controllers under each tab remains.

The solution that seems most likely to work is,

https://github.com/grgcombs/IntelligentSplitViewController/blob/master/IntelligentSplitViewController.m

Though this code is undoubtedly clever, it's a bit too 'side door' for me. I suspect (but don't know) that just invoking the delegate methods is not sufficient. Surely the UISplitViewController itself needs to change it's internal state as well as calling the delegate methods? This method 'just' invokes the delegate methods when there's an orientation change.

So... I've decided on a more legitimate solution, which is to use the new method introduced in iOS 5.

- (BOOL) splitViewController:(UISplitViewController *)svc
             shouldHideViewController:(UIViewController *)vc
             inOrientation:(UIInterfaceOrientation)orientation
{
     return NO;
}

So, the master menu is never hidden, and therefore the problem of managing the popover doesn't arise.

Of course, this is still not totally 'legit' as it still includes UISplitViewControllers that are not at the top level (the UITabViewController is at the top level, and the split views are on each tab)

Good luck with whichever solution you choose.

I'll update this reply when I've confirmed Apple will approve an app using this solution.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!