我觉得我已经触及了阻止它的每一个可能的原因,但是我的 Storyboard 中有一个 UIScrollView 与一个插座相连,在 viewDidLoad 中我设置了 contentSize 以便我可以滚动(是的,比我的框架大大小)!
I feel like I have touched on every single possible cause for stopping this, but I have a UIScrollView in my Storyboard hooked up with an outlet and in the viewDidLoad I set the contentSize so that I can scroll (yes bigger than my frame size)!
但是,无论我更改什么,我都无法滚动!我的滚动视图中有几个文本字段并启用了弹跳功能,因此我可以看到,在使用其中的子视图测试其上下移动时,但是无论我将 contentSize 设置为什么,我都无法滚动.
However, whatever I change, I just can't scroll! I have a couple of textfields in my scrollview and bouncing enabled so I can see that when testing its moves up and down with my subviews in it but whatever I set the contentSize to I just can't scroll.
有什么我可能遗漏/应该检查的吗?这是在故事板中使用 UIScrollView 的已知问题吗?
Anything I might be missing/should check? Is this a known issue with UIScrollView being used in a storyboard?
更奇怪的是,我可以这样做:[scrollView setBackgroundColor:[UIColor blueColor]]; 我有一个蓝色滚动视图!但是设置内容大小失败.
Whats even stranger is, I can do something like this:
[scrollView setBackgroundColor:[UIColor blueColor]]; and I have a blue scroll view! But setting content size fails.
我唯一的代码(否则滚动视图只是放入情节提要视图控制器中):
My only code (otherwise scrollview is just dropped into storyboard view controller):
-(void)viewDidAppear:(BOOL)animated
{
[scrollView setContentSize:CGSizeMake(320, 640)];
}
记录的帧,按预期出现:
Logged frame, comes out as expected:
width: 320.00
height: 504.00
事实证明,在我的故事板中删除滚动视图的任何子视图可以让它滚动得很好.如果我通过情节提要向它添加任何子视图,即使是一个空白的全新 UIButton,它也不会应用 contentSize/允许滚动.
Turns out that removing any subviews of the scroll view in my storyboard lets it scroll just fine. If I add any subview to it at all via the storyboard, even a blank brand new UIButton it just won't apply the contentSize/allow scrolling.
使用ViewDidLayoutSubview
use ViewDidLayoutSubview
- (void)viewDidLayoutSubviews
{
[_scrollView setContentSize:CGSizeMake(320, 500)];
}
UIViewController的方法调用顺序如下
UIViewController's method invoke sequence is as below
这篇关于故事板 UIScrollView contentSize?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 Xcode 4 的 Interface Builder 中滚动 UIScrollViewScrolling through UIScrollView in Interface Builder for Xcode 4(在 Xcode 4 的 Interface Builder 中滚动 UIScrollView)
创建类似于主视图的跳板Create springboard like main view(创建类似于主视图的跳板)
检查 UIScrollView 中的滚动方向Check direction of scroll in UIScrollView(检查 UIScrollView 中的滚动方向)
UIScrollView 不滚动?UIScrollView Not Scrolling?(UIScrollView 不滚动?)
UIScrollView 如何从其子视图中窃取触摸?How does UIScrollView steal touches from its subviews?(UIScrollView 如何从其子视图中窃取触摸?)
iPhone 自动滚动 UITextView 但也允许手动滚动iPhone Auto-scroll UITextView but allow manual scrolling also(iPhone 自动滚动 UITextView 但也允许手动滚动)