本文介绍了如何在 Xcode 7.2 上使用 Storyboard 布置比屏幕高的屏幕内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 swift 2.0 进行编程,但我对在视图控制器上添加更多对象感到困惑.例如,我的视图控制器上需要 14 个具有所需约束的按钮.但是我只能在故事板上的视图控制器中一一添加 7 个按钮.因为没有更多的地方可以在视图控制器上添加对象.那么,如何在故事板上的视图控制器中添加对象数量?请参考以下屏幕截图.感谢朋友们的帮助.

I use swift 2.0 for programming and I'm confused with adding more objects on view controller. For example, I need 14 buttons on my view controller with required constraints. But I'm able to add only 7 buttons one by one in my view controller on story board. Because no more place to add objects on view controller. So, How to add number of objects in view controller on story board?. Please refer following screen shots. Thanks for your help friends.

故事板上的视图控制器:

我只能添加 7 个具有适当约束的按钮.但我需要添加 14 个具有适当约束的按钮.当视图控制器滚动时,按钮 8 到 14 将分别显示按钮 1 到 7.

I'm able to add only 7 buttons with proper constraints. but i need to add 14 buttons with proper constraints. when view controller is scrolled then the button 8 to 14 will shown one by one respectively button 1 to 7.

没有滚动视图的 iPhone 5 上的输出:

带有滚动视图的 iPhone 4s 上的输出:

我在 iPhone 5 上需要这样,但有 14 个按钮.8到14个按键分别排列成1到7个按键.

I need like this on iPhone 5 , but 14 buttons. The 8 to 14 buttons arranged respectively 1 to 7 buttons.

推荐答案

你可以把它放在 Storyboard 中.

You can lay this out in a Storyboard.

  1. 单击您的 viewController,然后在 Size Inspector 中,将 Simulated Size 设置为 Freeform 并将宽度设置为3201136 的高度.这将为您提供一个又高又瘦的布局.

  1. Click on your viewController, and then in the Size Inspector, set the Simulated Size to Freeform and set the width to 320 and the height to 1136. This will give you a tall skinny layout.

为此添加一个滚动视图.将滚动视图调整为全屏.将它的所有四个边固定到它的 superView.

Add a scrollView to that. Size the scrollView to the full screen. Pin all four of its sides to its superView.

在高视图控制器中布置 14 个按钮.

Lay out your 14 buttons in the tall viewController.

当你运行时,你的 contentView 会滚动.

When you run, your contentView will scroll.

这篇关于如何在 Xcode 7.2 上使用 Storyboard 布置比屏幕高的屏幕内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 01:50