iOS:在故事板中将子类从UIView更改为UIScrollView [英] iOS: Changing subclass from UIView to UIScrollView in a storyboard
问题描述
我创建了一个基于故事板的项目。在其中一个视图控制器的视图中,需要放置一些额外的元素,这会导致视图高度增加,从而视图现在必须是可滚动的。是否可以在故事板中简单地将UIView的类类型更改为UIScrollView?它真的会将顶级UIView转换为UIScrollView吗?只是在没有太多变化的情况下寻找快速简便的方法。
I have created a storyboard based project. In one of the view controller's view requires some extra elements to be placed which results in increasing the view height such that the view must now be scrollable. Is it possible to simply change the class type of UIView to UIScrollView in storyboard? Will it really convert the top level UIView to UIScrollView ? Just looking for a quick and easy way of doing this without much changes.
谢谢
推荐答案
您必须将 UIView
类型更改为 UIScrollView
(身份检查员)并在控制器中 viewDidLoad
方法通过将视图转换为 UIScrollView $ c $来为视图分配
contentSize
c>:
You have to change the UIView
type to UIScrollView
(identity inspector) and in the controller viewDidLoad
method assign the view a contentSize
by casting the view to a UIScrollView
:
[(UIScrollView *)self.view setContentSize:CGSizeMake(320, 700)];
这篇关于iOS:在故事板中将子类从UIView更改为UIScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!