简体   繁体   English

iPhone:如何将反面视图变成滚动的UIScroll视图?

[英]iPhone: How can I turn a flipside view into a scrolling UIScroll view?

This should be simple. 这应该很简单。 I'm making a very basic app, based on the Utility Application template of XCode. 我正在基于XCode的Utility Application模板制作一个非常基础的应用程序。 On the flipside, I have more content than fits the screen. 另一方面,我的内容超出了屏幕尺寸。 The flipside is a UIView. 缺点是UIView。 I think it should be a UIScrollView, but somehow I don't get it to work. 我认为它应该是UIScrollView,但是不知何故我无法使用它。 Can anybody here advise me on this? 这里有人可以建议我吗?

With a UIScrollView it is not enough just to place the control into Interface Builder and place the items within it; 使用UIScrollView仅仅将控件放入Interface Builder并在其中放置项目是不够的。 you have to set its content size in code. 您必须在代码中设置其内容大小。

Therefore in the -viewWillAppear method (or similar) you should have something like: 因此,在-viewWillAppear方法(或类似方法)中,您应具有以下内容:

[scrollView setContentSize:CGSizeMake(320, 600];

This would make the content size inside the scroll view 600 pixels high (ie larger than the height of your iPhone display). 这将使滚动视图内的内容大小高600像素(即,大于iPhone显示屏的高度)。 If everything else is wired up correctly, this shoud now work. 如果其他所有设备都正确连接,则此方法现在可以正常工作。

Note: You may also then need to reposition your objects within the view. 注意:然后,您可能还需要在视图中重新放置对象。 Set frame.origin for the objects that require this... 为需要此设置的对象设置frame.origin ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM