UIScrollView will not scroll, even after content size set(UIScrollView 不会滚动,即使在内容大小设置后)
问题描述
我的 UIScrollView 是一个大约 4500 像素的水平视图,用户需要水平滚动才能查看内容.
我设置如下:
- (void)viewDidLoad{[超级视图DidLoad];sview.frame = CGRectMake(0, 0, 568, 320);sview.contentSize = CGSizeMake(4500, 320);[sview setScrollEnabled:YES];}
然而滚动视图什么也没做.有什么明显的我错过了吗?我已经尝试过网络上的每个教程.
我遇到了类似的问题.我做了以下修改,scrollView 开始为我滚动:
- 选择以检查 UIScrollView 的水平反弹"属性在西布.
- 将代码后面的代码移动到 viewDidAppear 而不是viewDidLoad:
<块引用>
-(void) viewDidAppear:(BOOL)animated{[超级 viewDidAppear:动画];sview.frame = CGRectMake(0, 0, 568, 320);sview.contentSize = CGSizeMake(4500, 320);[sview setScrollEnabled:YES];}
我认为这应该对你有所帮助.
My UIScrollView is a ~4500px horizontal view that the user needs to scroll horizontally through to view the content.
I have set it up as follows:
- (void)viewDidLoad
{
[super viewDidLoad];
sview.frame = CGRectMake(0, 0, 568, 320);
sview.contentSize = CGSizeMake(4500, 320);
[sview setScrollEnabled:YES];
}
Yet the scroll view does nothing. Is there something obvious I missed? i've tried literally every tutorial on the web.
I got similar issue. I did following modifications and the scrollView started scrolling for me:
- Select to check the 'Bounce Horizontally' property for UIScrollView in xib.
- Move the code following code to viewDidAppear instead of viewDidLoad:
-(void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; sview.frame = CGRectMake(0, 0, 568, 320); sview.contentSize = CGSizeMake(4500, 320); [sview setScrollEnabled:YES]; }
I think this should help you.
这篇关于UIScrollView 不会滚动,即使在内容大小设置后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIScrollView 不会滚动,即使在内容大小设置后
基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01