Adding items to scrollview in storyboard (size inspector appears to be locked)(在情节提要中将项目添加到滚动视图(尺寸检查器似乎已被锁定))
问题描述
我使用情节提要在我的视图控制器中添加了一个内容大小大于屏幕大小的滚动视图.当然,滚动视图的目的是让内容大于包含它的视图.我想在情节提要中以图形方式将按钮和标签添加到滚动视图的底部,但我无法查看滚动视图的那部分.我如何到达那里.几周前我第一次添加视图时,我尝试在尺寸检查器中进行调整,但它没有让我改变任何东西.
I've added a scrollview with a content size that is larger than the screen size in my view controller using storyboard. Of course the purpose of the scrollview is to have content larger than the view that contains it. I would like to add buttons and label to the bottom of the scrollview graphically in storyboard, but I can't view that part of the scrollview. How do I get there. I tried adjusting in the size inspector which worked for me when I first added the view a few weeks ago, but it don't let me change anything.
推荐答案
我能够在 UIScrollView
中编辑我的内容的唯一方法(这可以追溯到故事板之前,但我很确定它仍然适用)是更改内容框架的 x 或 y 的偏移量.
The only way I've been able to edit my content in a UIScrollView
(and this dates back to way before the Storyboard, but I'm pretty sure it still applies) is to change the offset of the x or y of your content frame.
另一个选项,取决于您的内容视图是否为静态"(内置于 .xib),实际上是将其拉到滚动视图之外,并在 viewDidLoad 中以编程方式将其设置为内容视图
什么的.
Another option, depending on whether your content view is "static" (built in the .xib) or not, is to actually pull it outside of the scroll view, and set it as the content view programmatically in viewDidLoad
or something.
希望这会有所帮助,如果有意义并且您需要它们,我可以跟进代码示例.
Hope this helps, I can follow up with code examples if it makes sense and you need 'em.
编辑(2012 年 2 月 10 日):这是一个如何将大视图连接到滚动视图的示例.在这个例子中,滚动视图(scrollView)被设置为视图控制器的视图属性.在 .xib 中,我还添加了一个名为 largeView 的 UIView
.两者在 .xib 文件中并没有以任何方式关联,它们只是都出现在那里.
EDIT (2/10/2012): Here's an example of how to hook up the larger view to your scroll view. In this example, the scroll view (scrollView) is set to the view controller's view property. In the .xib I've also added a UIView
named largerView. The two are not hooked up in any way in the .xib file, they just both appear there.
鉴于...
@property (nonatomic, retain) IBOutlet UIView *largeView;
@property (nonatomic, retain) IBOutlet UIScrollView *scrollView;
在 viewDidLoad:
我们只是...
// add the largeView to the main scrollView
[scrollView addSubview:largeView];
[scrollView setContentSize:largeView.frame.size];
这可能是最简单的例子.祝你好运!
This is probably the simplest possible example though. Good luck!
这篇关于在情节提要中将项目添加到滚动视图(尺寸检查器似乎已被锁定)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在情节提要中将项目添加到滚动视图(尺寸检查器
基础教程推荐
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01