在storyboard中向scrollview添加项目(大小检查器似乎已锁定) [英] Adding items to scrollview in storyboard (size inspector appears to be locked)

查看:85
本文介绍了在storyboard中向scrollview添加项目(大小检查器似乎已锁定)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了一个内容大小的滚动视图,该内容大小比我在视图控制器中使用情节提要的屏幕尺寸大。当然,scrollview的目的是让内容大于包含它的视图。我想在故事板中以图形方式在滚动视图的底部添加按钮和标签,但我无法查看滚动视图的那一部分。我如何到达那里。几周前,当我第一次添加视图时,我尝试调整尺寸检查器,但它不会让我改变任何东西。

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.

编辑(2) / 10/2012):这是一个如何将较大的视图连接到滚动视图的示例。在此示例中,滚动视图(scrollView)设置为视图控制器的视图属性。在.xib中我还添加了名为greaterView的 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:我们只是......

In viewDidLoad: we just...

// 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!

这篇关于在storyboard中向scrollview添加项目(大小检查器似乎已锁定)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆