使用iOS中的选项卡更改容器视图内容 [英] Change Container View Content with Tabs in iOS

查看:90
本文介绍了使用iOS中的选项卡更改容器视图内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个跨越三个标签的表单。您可以在下面的屏幕截图中看到选项卡的位置。当用户点击选项卡时,容器视图应该更新并显示我拥有的特定视图控制器。

I'm trying to make a form that spans three tabs. You can see in the screenshot below where the tabs will be. When the user taps a tab, the Container View should update and show a particular view controller I have.

标签1 =查看控制器1

Tab 1 = View Controller 1

选项卡2 =查看控制器2

Tab 2 = View Controller 2

选项卡3 =查看控制器3

Tab 3 = View Controller 3

上面显示的视图控制器具有类PPAddEntryViewController.m。我在这个类中为Container视图创建了一个插座,现在有一个Container View属性:

The view controller shown above has the class PPAddEntryViewController.m. I created an outlet for the Container view within this class and now have a Container View property:

@property (weak, nonatomic) IBOutlet UIView *container;

我也准备好了我的IBActions:

I also have my IBActions for my tabs ready:

- (IBAction)tab1:(id)sender {
  //...
}
- (IBAction)tab2:(id)sender {
  //...
}
- (IBAction)tab3:(id)sender {
  //...
}

如何在这些IBActions中设置容器来更改容器视图所包含的视图控制器?

在其他一些事情中,这是我尝试过的事情:

Among a few other things, here's what I've tried:

UIViewController *viewController1 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc1"];
_container.view = viewController1;

...但它不起作用。在此先感谢。

...but it doesn't work. Thanks in advance.

推荐答案

我最近找到了完美示例代码,用于我尝试做的事情。它包括Storyboard实现和所有相关的segue和代码。这真的很有用。

I recently found the perfect sample code for what I was trying to do. It includes the Storyboard implementation and all the relevant segues and code. It was really helpful.

https://github.com / mhaddl / MHCustomTabBarController

这篇关于使用iOS中的选项卡更改容器视图内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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