UIScrollView cannot see ScrollBars/Indicators.(UIScrollView 看不到 ScrollBars/Indicators.)
问题描述
我以编程方式创建了一个 UISCrollView,但我看不到滚动条/指示器.
I programatically created a UISCrollView but i cant see the scrollbars/indicators.
UIScrollView * contentScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(760, 70, 205, 320)];
contentScrollView.delegate = self;
contentScrollView.scrollEnabled = YES;
contentScrollView.pagingEnabled = YES;
contentScrollView.userInteractionEnabled=YES;
contentScrollView.scrollsToTop = YES;
contentScrollView.showsVerticalScrollIndicator = NO;
contentScrollView.showsVerticalScrollIndicator = YES;
contentScrollView.alwaysBounceVertical = NO;
contentScrollView.alwaysBounceHorizontal = NO;
contentScrollView.bounces = NO;
contentScrollView.hidden = NO;
[contentScrollView flashScrollIndicators];
UILabel *titleLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 205, 40)];
UILabel *subtitleLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 205, 50)];
UITextView * mainContent = [[UITextView alloc]initWithFrame:CGRectMake(10, 110, 205, 230)];
[titleLable setText:@"...."];
[subtitleLable setText:@"SUbtitle"];
[mainContent setText:@"Descritpon"];
[contentScrollView addSubview:mainContent];
[contentScrollView addSubview:titleLable];
[contentScrollView addSubview:subtitleLable];
我将这段代码添加到一个视图中,该视图再次附加到另一个更大的滚动视图.有谁知道为什么会这样?同样为简单起见,我将每个标签包含的文本减少为单词,但在程序中我的文本足以滚动
This code i add it to a view which is again attached to another bigger scrollview.. Does anyone know why this is the case? Also for simplicity i have reduced the text each lable contains to words but in the program i have the text is sufficient to scroll
谢谢..
推荐答案
要让滚动视图滚动,滚动视图的内容大小必须大于其边界.请添加此行然后检查:
For the scroll view to scroll, the content size for the scroll view must be greater than its bounds. Please add this line and then check:
contentScrollView.contentSize=CGSizeMake(320, 250);
并将 contentScrollView.bounces
设置为 YES
并删除 contentScrollView.showsVerticalScrollIndicator=YES
行,因为您首先将值设置为NO
然后 YES
.
and also set the contentScrollView.bounces
to YES
and remove the line contentScrollView.showsVerticalScrollIndicator=YES
as you have first set the value to NO
and then YES
.
这应该可以完成工作.
这篇关于UIScrollView 看不到 ScrollBars/Indicators.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIScrollView 看不到 ScrollBars/Indicators.


基础教程推荐
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01