作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个问题,我将 UIScrolview 添加到我的 UIViewController,但我的 UIScrollview 不想滚动。我希望它的工作方式与在 UITableViewController 上的工作方式相同。
在这里我初始化我的 UIScrollview
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 800)];
scroll.contentSize = CGSizeMake(320, 800);
scroll.backgroundColor = [UIColor redColor];
scroll.showsHorizontalScrollIndicator = YES;
scroll.scrollEnabled = YES;
scroll.userInteractionEnabled=YES;
[self.view addSubview:scroll];
UILabel *memberNo = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 20)];
memberNo.text = @"Member No";
memberNo.font = [UIFont boldSystemFontOfSize:16];
memberNo.textColor = [UIColor limeColor];
[scroll addSubview:memberNo];
memberText = [[UITextField alloc] initWithFrame:CGRectMake(10, 40, 300, 30)];
memberText.placeholder = @"Member No";
memberText.borderStyle = UITextBorderStyleRoundedRect;
memberText.text = @"1111111";
[scroll addSubview:memberText];
最佳答案
试试这个
设置内容大小大于屏幕大小,无论是否有更多内容,它都会滚动
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 800)];
scroll.contentSize = CGSizeMake(320, 900);
scroll.contentSize = CGSizeMake(340, 800);
关于UIScrollview 不滚动我做错了什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17131698/
我是一名优秀的程序员,十分优秀!