UIScrollView 不会滚动,即使在内容大小设置后
- 作者: 奘莼莼
- 来源: 51数据库
- 2022-10-25
问题描述
我的 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.
推荐阅读
热点文章
检查拆分键盘
0
带有“上一个"的工具栏和“下一个"用于键盘输入AccessoryView
0
Activity 启动时显示软键盘
0
UIWebView 键盘 - 摆脱“上一个/下一个/完成"酒吧
0
在 iOS7 中边缘滑动时,使键盘与 UIView 同步动画
0
我的 iOS 应用程序中的键盘在 iPhone 6 上太高了.如何在 XCode 中调整键盘的分辨率?
0
android:inputType="textEmailAddress";- '@' 键和 '.com' 键?
0
禁用 iPhone 中键盘的方向
0
Android 2.3 模拟器上的印地语键盘问题
0
keyDown 没有被调用
0
