简体   繁体   English

使用UITabbar的UISplitView

[英]UISplitView with UITabbar

I have a strange one that I can not seem to fix. 我有一个奇怪的,我似乎无法解决。 I am currently working on updating my app to iOS7. 我目前正在努力将我的应用更新到iOS7。 This all worked in iOS6. 这一切都在iOS6中有效。 It is an universal app and thus uses same xib files. 它是一个通用应用程序,因此使用相同的xib文件。 However the iPad uses UISplitViews on some. 然而,iPad在某些上使用了UISplitViews。 Like I said, this all worked in iOS6 oh this all works on the iPhone too. 就像我说的,这一切都适用于iOS6哦,这一切都适用于iPhone。

The problem is a grey bar at the bottom. 问题是底部是灰色条。 I changed the tab bar to be opaque to move views up properly as i had some UI clipped to bottom of views and that went underneath the tab bar, sidetracked there. 我将标签栏更改为不透明以正确移动视图,因为我将一些UI剪切到视图底部并且位于标签栏下方,在那里进行了侧移。 But if i set it back to translucent bar, it goes underneath but stretched properly. 但是,如果我将它设置回半透明条,它会在下方但正确拉伸。 if i dont, it adds a bar. 如果我不这样做,它会添加一个条形码。 Other tabs work fine when NOT using splitview. 其他选项卡在不使用splitview时工作正常。

The UISplitviewController is added programmatically. UISplitviewController以编程方式添加。

See attached image for better description. 有关更好的说明,请参见附图。

灰色条位于我的splitview和tabbar之间

This I have tried: 我试过这个:

  • Added autoresize on splitview 在splitview上添加了自动调整大小
  • Checked xib for subviews in the splitviews to have auto resize 已检查xib以查看拆分视图中的子视图以自动调整大小
  • Tried to force splitview to be screen bounds 试图强制splitview成为屏幕边界
  • Removed clips to bounds on all views 删除了所有视图上绑定的剪辑
  • Removed autoresize subviews 删除了自动调整大小的子视图

Any ideas would be welcomed. 任何想法都会受到欢迎。

Thank you all. 谢谢你们。

UPDATE: 更新:

setting the background colour the uisplitview, it does colour the bar black. 设置uisplitview的背景颜色,它会使条纹黑色。 So the uisplitview is definitely stretching to it. 所以uisplitview肯定会延伸到它。

我将UISplitViewController子类化,并将下面的行添加到viewDidLoad并修复了灰线。

self.extendedLayoutIncludesOpaqueBars = YES;

I believe I have found an alternative solution for you. 我相信我已经找到了替代解决方案。 I have had the exact same problem, mostly because we are both doing something against Apple's Guidelines which is having a SplitViewController nested within a Tabbar controller (SplitView should be the root view). 我遇到了完全相同的问题,主要是因为我们都在针对Apple的指南做了一些事情,它有一个嵌套在Tabbar控制器中的SplitViewController(SplitView应该是根视图)。 This was okay in iOS 5/6, but now in iOS 7 there are far too many side effects to achieve this. 这在iOS 5/6中没问题,但现在在iOS 7中有太多的副作用来实现这一点。

The reason you see your view stretch completely when you set the bar to be translucent is because the bar is NOT taken into account when drawing the view. 当您将条形设置为半透明时,您看到视图完全拉伸的原因是因为绘制视图时不考虑条形。 When you set translucent to false, it is then taken into account of the view and you will see that grey bar there because that's your view pretending there's a tabbar at the bottom of the screen. 当您将半透明设置为false时,会将其考虑在视图中,您将看到那里的灰色条,因为您的视图假装在屏幕底部有一个标签栏。

And as always, a SplitViewcontroller's height cannot be changed, as it is determined by the visible window height. 和往常一样,SplitViewcontroller的高度无法更改,因为它由可见窗口高度决定。

I tried everything you did and then some. 我尝试了你所做的一切,然后是一些。 The real solution came from using a third-party Split View Controller. 真正的解决方案来自使用第三方拆分视图控制器。

I recommend switching over to https://github.com/mattgemmell/MGSplitViewController . 我建议切换到https://github.com/mattgemmell/MGSplitViewController This split view controller is actually one large View with container views living inside of it. 这个拆分视图控制器实际上是一个大视图,其中包含容器视图。 Because of this, you avoid all the side effects of putting an actual split view controller within a tab bar. 因此,您可以避免将实际拆分视图控制器放在选项卡栏中的所有副作用。

If that doesn't float your boat, you could create your own solution which follows the same idea of having one UIViewController with two container views contained in it, though the people behind MGSplitViewController did a good job of that already. 如果这不会漂浮你的船,你可以创建自己的解决方案,遵循相同的想法,让一个UIViewController包含两个容器视图,虽然MGSplitViewController背后的人已经做得很好。

This was the only way I was able to solve this issue, let me know if you find an alternative. 这是我能够解决这个问题的唯一方法,如果您找到替代方案,请告诉我。

我没有为UISplitViewController创建子类, UISplitViewController在我的master的viewDidLoad上添加了这段代码:

self.splitViewController?.extendedLayoutIncludesOpaqueBars = true

For the controller that is the detail view of UISplitViewController you just do this: 对于作为UISplitViewController的详细视图的控制器,您只需执行以下操作:

-(UITabBarController*)tabBarController{
    return nil;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM