在情节提要中将项目添加到滚动视图(尺寸检查器

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!

这篇关于在情节提要中将项目添加到滚动视图(尺寸检查器似乎已被锁定)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在情节提要中将项目添加到滚动视图(尺寸检查器

基础教程推荐