Sometimes willHideViewController from UISplitViewControllerDelegate is not called

I have a problem. My application is a tab bar controller, and its first view controller is a split view controller. This does not seem to be normal for Apple, because the docs say that the shared stream controller should be root, so maybe this is the cause of my problems.

The problem is that sometimes, willHideViewController from UISplitViewControllerDelegate is not called, so for this reason the top / left button is sometimes not created, which is anonymous. I realized, to reproduce this error, try several times: -Landscape mode. -Select a tab other than the controller tap. -Translate iPad to portrait on this tab. -Go to the tab of the split view manager, and sometimes, HideViewController is not called, so you will not see the top button. However, if I rotate my iPad to the landscape and then to the portrait, it is corrected.

I tried manually manually a few turns to get around this problem, but no luck. I still have to try any clone controller class of the view class from github or similar. Do you have an idea what is happening or some kind of work?

Here I will show you two examples that work correctly.

enter image description hereenter image description here Many thanks for your help.

+4
source share
2 answers

Where do you install the splitViewControllers delegate? Perhaps you can set the delegate when loading the tab. It looks like you installed it only when you turned once?

Otherwise, see this example.

Here they have a TableViewController - this is a delegate from splitviewcontroller. Perhaps you can do the same with TabBarController?

0
source

I came to the conclusion that this cannot be done in any way, which I consider to be "sufficiently" legal. This may be disappointing, but the question of whether willShow ... will have to apply to split view controllers under each tab.

The solution that is likely to work,

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

Although this code is undoubtedly smart, for me it is too β€œa side door”. I suspect (but don't know) that simply using delegate methods is not enough. Of course, the UISplitViewController itself needs to change its internal state, as well as call delegate methods? This method simply calls delegate methods when the orientation changes.

So ... I decided to use a more legitimate solution, which should use the new method introduced in iOS 5.

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

So, the main menu is never hidden, so the popover control problem does not arise.

Of course, this is still not completely β€œlegal”, since it still includes UISplitViewControllers that are not at the top level (UITabViewController is at the top level, and split views are on each tab)

Good luck with the solution you have chosen.

I will update this answer when I confirm that Apple will approve an application using this solution.

0
source

Source: https://habr.com/ru/post/1391167/


All Articles