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.
基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01