如何将 SplitView 更改为 UITabBarController 中的另一个视图,如 Yelp iPad 应用程序中那样
我想在 UITabBarController 中创建一个视图,如 iPad 应用程序所示(请参阅下面的图像链接 [1] [2]),其中默认视图是分割视图,通过单击“照片”,分割视图将替换为另一个视图。两个视图都显示在同一个选项卡项中。
我现在可以在选项卡栏中创建分割视图,这意味着我可以创建类似于第一张图片所示的内容,但如何用另一个视图替换分割视图?
我尝试将 UISplitViewController 分配给另一个 UIViewController,但它不起作用。
由于无法发图片,链接如下: http://ww3.sinaimg.cn/large/7811c8e9gw1dphto6x47wj.jpg [1] http://ww3.sinaimg.cn/large/7811c8e9gw1dphtpj1ltaj.jpg [2]
I want to created a view in UITabBarController as the iPad App shown (see image links below [1] [2]), where the default view is a split view and by clicking on "Photo", the split view is replaced as another view. And both views are displayed in the same tab item.
I am able to create split view within tab bar now, which means I can create something like what the first picture shows, but how to replace the split view with another view?
I have tried to assign the UISplitViewController with another UIViewController, but it doesn't work.
As I can't post images, here are the links:
http://ww3.sinaimg.cn/large/7811c8e9gw1dphto6x47wj.jpg [1]
http://ww3.sinaimg.cn/large/7811c8e9gw1dphtpj1ltaj.jpg [2]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只是在 UISplitViewController 前面添加一个 UINavigationController (在 UITabBarController 和 UISplitViewController 之间)。当用户切换 UISegmentedControl 时,您需要的全屏视图将被推送到 UISplitViewController 上。这是故事板。 (但是,我无法粘贴任何照片。)
要在主视图或详细视图中访问 UINavigationController,您可以使用
[self.splitViewController.navigationController PushViewController:fullScreenViewControllerAnimated:YES];
。
由于您不希望 UINavigationController 的导航栏出现在 splitView 中,因此需要对 UISplitViewController 进行子类化。然后在viewDidApplear中隐藏导航栏:
您可以参考一些问题,例如 How to隐藏主视图或如何显示详细视图在全屏模式。您还可以尝试这个自定义的 UISplitViewController MGSplitViewController,它可以在任何情况下切换主视图和详细视图。
I simply add a UINavigationController in front of the UISplitViewController(between the UITabBarController and the UISplitViewController). When the user toggles the UISegmentedControl, the fullscreen view you need will be pushed onto the UISplitViewController. Here is the storyboard. (But, I can`t paste any photo.)
To access the UINavigationController in the master view or detail view, you can use
[self.splitViewController.navigationController pushViewController:fullScreenViewController animated:YES];
.
Since you don`t want the navigation bar of the UINavigationController to appear in the splitView, you need to subclass the UISplitViewController. Then hide the navigation bar in the viewDidApplear:
You can refer to some questions like How to hide the master view or How to display the detail view in a full screen mode. You can also try this customized UISplitViewController MGSplitViewController, which can toggle the master view and detail view in any situation.