ScrollView中的UIScrollView - ScrollBars未显示 [英] UIScrollView within ScrollView - ScrollBars not showing

查看:146
本文介绍了ScrollView中的UIScrollView - ScrollBars未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

BackStory

我正在编写一个ipad应用程序,其中包含使用UIScrollView水平滚动的图像。这很好用。现在,对于每个图像,我需要有一个UIScrollView,它有一些解释图像的文本。这将是一个垂直scrollView。出现垂直ScrollView,但滚动条不会出现。知道为什么吗?代码如下:

I am writing an ipad app which has images that scrolls horizontally using a UIScrollView. This works fine. Now for each image i need to have a UIScrollView which has some kind of text explaining the image. This would be a vertical scrollView. The vertical ScrollView appears but then the scrollbars dont appear. Any idea why? Code below :

CGRect scrollViewFrame = CGRectMake(760, 70, 205, 320);
UIScrollView * contentScrollView = [[UIScrollView alloc]initWithFrame:scrollViewFrame];
[contentView addSubview:contentScrollView];
CGSize scrollViewContentSize = CGSizeMake(205, 100);
[contentScrollView setContentSize:scrollViewContentSize];
[contentScrollView setPagingEnabled:YES];
contentScrollView.delegate = self;

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:storyTitle];
[subtitleLable setText:storySubTitle];
[contentView setUserInteractionEnabled:YES];
[mainContent setText:storyDescription];

此外,主要的scrolView已经使用Interface Builder添加,并且工作正常。 wnyone知道为什么会这样吗?

Also the main scrolView is already added using Interface Builder and is working fine. Does wnyone know why this is happening?

推荐答案

滚动视图仅显示滚动条,允许用户在内容大小大于滚动视图大小时滚动,如我所见在您的代码中,滚动视图大小为(205,320),而内容大小仅为(205,100)。

The scroll view only shows scroll-bar and allows user to scroll whenever content size larger than scroll view size, as I see in your code, scroll view size is (205, 320) while content size is only (205, 100).

这篇关于ScrollView中的UIScrollView - ScrollBars未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆