iPhone 应用程序窗口中的可切换子视图

发布于 2024-11-25 16:43:59 字数 298 浏览 0 评论 0原文

我一直在到处寻找,但似乎找不到任何适合我的情况的示例/教程(不知道如何谷歌它..) 所以我有一个窗口,其中一部分应该是静态的(按钮等),并且有一个动态部分(左下角)应该更改子视图。
所以我正在寻找一种方法,以便单击静态区域中的按钮将动态区域更改为我选择的视图。我不知道如何使用 IB 来做到这一点,但以编程方式进行似乎是唯一的方法。有什么建议(我不想使用标签栏控制器)?
灰色为静态区域 哦,以编程方式发表观点与通过 IB 相比有什么好处吗?

谢谢!

I've been looking everywhere but can't seem to find any examples/tutorials for my situation (not sure how to google it..)
So i have a window where a portion of it should be static (buttons and such) and there is a dynamic part (bottom leftish) that should change subviews.
So what i'm looking for is a way so that clicking the buttons in the static area will change the dynamic area to a view of my choice. I have no idea how to do this using the IB, but doing it programatically seems the only way. Any suggestions(I do not want to use a tab bar controller)?
grey is static area
Oh, and is there a benefit to making views and such programatically vs through the IB?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一页 2024-12-02 16:43:59

您也可以通过编程来实现它。只需创建另一个视图控制器类(您想要多少个)。在它的 loadView 方法中,在当前视图中要添加子视图的坐标中创建一个 UIView 。现在在当前视图控制器中创建此视图控制器类的实例并将其添加为子视图。您将在所需位置获得子视图。如果您想动态更改它,请创建尽可能多的视图,然后将它们添加到数组中,并在单击按钮时更改它们。
希望这有帮助。

You can also achieve it programatically. Just create another viewcontroller class (as many as u want). In the loadView method of it create a UIView in the coordinates where u want to add the subview in the current view. Now create an instance of this viewcontroller class in the currentview controller and add it as a subview. You will get the subview at the desired location.If u want to change it dynamically create as many views and then add them to the array and change them whenever the button is clicked.
Hope this helps.

囍孤女 2024-12-02 16:43:59

您应该在视图控制器中执行切换。静态按钮可以将其操作连接到该控制器(在 IB 中),该控制器可以有一个到子视图的出口(在 IB 中)并执行交换。

至于何时应该使用 IB,请参阅此问题

You should perform the switch in your view controller. The static buttons can have their actions hooked up to that controller (in IB), which can have an outlet (in IB) to the subviews and perform the swap.

As for when you should use IB, see this question.

旧情别恋 2024-12-02 16:43:59

您也可以通过界面生成器来完成此操作。您只需将 viewController 从界面生成器拖放到主窗口即可。将 IBAction 分配给所有按钮以将不同的 viewController 的视图添加到主窗口只是使它们的框架更小。

You can do it from interface builder as well. You just need to take viewController from interface builder drag-n-drop to main window. assign IBAction to all buttons to add different viewController's view to main window just make their frame some smaller.

渔村楼浪 2024-12-02 16:43:59

如果您想通过单击按钮来更改或查看,那么您选择了分段控制开关。和每个段的代码,就像单击段 0 然后打开第一个子视图一样,当单击段 1 然后打开第二个子视图时。并默认取消选择,以便您的静态视图最初会出现在视图中。

if u want to change or views by click on button then u chose segmentcontrol switch. and cod for each segment like as when click on segment 0 then open first sub view and when click on segment1 then open second sub view. And make by default unselected so that ur static view will appear initially lunching of view.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文