有时来自UISplitViewControllerDelegate的willHideViewController不会被调用 [英] Sometimes willHideViewController from UISplitViewControllerDelegate is not called

查看:120
本文介绍了有时来自UISplitViewControllerDelegate的willHideViewController不会被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题。
我的应用程序是一个标签栏控制器,它的第一个视图控制器是一个拆分视图控制器。
这似乎不适合Apple,因为文件说拆分voew控制器必须是root,所以也许这就是我遇到问题的原因。

I have a problem. My app is a tab bar controller and its first view controller is a split view controller. This seems to be not ok for Apple because documents say a split voew controller must be the root, so perhaps that is the reason of my problems.

问题是,有时,来自UISplitViewControllerDelegate的willHideViewController没有被调用,因此,有时候不会创建上/左按钮,这很烦人。
我意识到,为了重现这个错误,请尝试几次:
-Landscape模式。
- 选择不同的选项卡以拆分视图控制器点击。
-在该标签中将iPad移至纵向。
- 转到拆分视图控制器选项卡,有时候,不会调用willHideViewController,因此您将看不到上方按钮。但是,如果我将我的iPad旋转到横向,然后再将其旋转为纵向,则它已修复。

The problem is that sometimes, willHideViewController from UISplitViewControllerDelegate is not called, so, for this reason, the upper/left button sometimes is not created, which is anoying. I realised, to reproduce this error, try several times this: -Landscape mode. -Select a tab different to split view controller tap. -Move the iPad to portrait in that tab. -Go to the split view controller tab, and sometimes, willHideViewController is not called so you will not see the upper button. However if I rotate my iPad to landscape and after that to portrait, it's fixed.

我试图强制手动多次旋转来解决这个问题,但没有运气。
我仍​​然需要尝试从github或类似的任何拆分视图控制器克隆类。
你知道发生了什么或者有什么解决方法吗?

I tried to force manually several rotations to work around this problem, but no luck. I still have to try any split view controller clone class from github or similar. Do you have idea what's going on or any work around?

这里我给你看两个正常工作的例子。

Here I show you two examples working properly.



非常感谢您的帮助。

Thanks a lot for your help.

推荐答案

我的结论是,这不能以我认为足够合法的任何方式完成。它可能会令人沮丧地接近,但是让willShow ...的问题仍然会传播到每个标签下的拆分视图控制器。

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

虽然这段代码无疑很聪明,但它有点过分了'侧门'对我来说。我怀疑(但不知道)只是调用委托方法是不够的。当然UISplitViewController本身需要改变它的内部状态以及调用委托方法吗?当方向发生变化时,这种方法只是调用委托方法。

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.

所以......我决定采用更合理的解决方案,即使用新方法iOS 5中引入的方法。

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;
}

因此,主菜单永远不会隐藏,因此管理不会出现popover。

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

当然,这仍然不是完全'合法',因为它仍然包括不在顶层的UISplitViewControllers(UITabViewController在最高级别,每个标签上的拆分视图)

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.

当我确认Apple将使用此解决方案批准某个应用时,我会更新此回复。

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

这篇关于有时来自UISplitViewControllerDelegate的willHideViewController不会被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆