How to use Storyboard to lay out screen content that is taller than the screen on Xcode 7.2?(如何在 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.
单击您的 viewController,然后在 Size Inspector 中,将 Simulated Size 设置为 Freeform 并将宽度设置为
320
和1136
的高度.这将为您提供一个又高又瘦的布局.
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 to1136
. 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 布置比屏幕高的屏幕内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Xcode 7.2 上使用 Storyboard 布置比屏幕高的屏


- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01