Iphone 如何在页面底部的UIScrollView中滚动UIView列表?

Iphone 如何在页面底部的UIScrollView中滚动UIView列表?,iphone,objective-c,ios4,Iphone,Objective C,Ios4,我想在我的ipad应用程序的uiscrollview中放置UIView列表而不是UIImageView作为内容。我使用ImageView滚动图像,但我需要UIView作为必须水平滚动的子视图列表?我尝试通过Interfacebuilder在uiscrollview中添加UIView,但在运行应用程序时,我只能看到一个uiview,因为所有剩余视图都不存在。请帮我解决这个问题 我试过这样做,但它仍然没有显示视图,而且我还试过以编程方式处理UIScrollView的维度,以及其中的视图,如下面的代

我想在我的ipad应用程序的uiscrollview中放置UIView列表而不是UIImageView作为内容。我使用ImageView滚动图像,但我需要UIView作为必须水平滚动的子视图列表?我尝试通过Interfacebuilder在uiscrollview中添加UIView,但在运行应用程序时,我只能看到一个uiview,因为所有剩余视图都不存在。请帮我解决这个问题


我试过这样做,但它仍然没有显示视图,而且我还试过以编程方式处理
UIScrollView
的维度,以及其中的视图,如下面的代码所示:

scrollView.frame=CGRectMake(0, 604, 728,365);
scrollView.bounces = YES;
scrollView.pagingEnabled = YES;
scrollView.backgroundColor = [UIColor darkGrayColor];
scrollView.delegate = self;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.userInteractionEnabled = YES;


UIView *subView1=[[UIView alloc]initWithFrame:CGRectMake(20, 604, 758,365)];
subView1.backgroundColor=[UIColor blueColor];
[scrollView addSubview:subView1];
[subView1 release];
UIView *subView2=[[UIView alloc]initWithFrame:CGRectMake(828, 604, 758,365)];
subView2.backgroundColor=[UIColor blueColor];
[scrollView addSubview:subView2];
[subView2 release];
[scrollView release];

需要时,您需要将UIView添加为。您需要使用编程方法来添加UIView。您应该看看Apple提供的PageControl示例代码。我希望你得到你的答案

UIView *subView1=[[UIView alloc]initWithFrame:CGRectMake(20, 604, 758,365)];
subView1.backgroundColor=[UIColor blueColor];
[scrollView addSubview:subView1];
[subView1 release];
UIView *subView2=[[UIView alloc]initWithFrame:CGRectMake(828, 604, 758,365)];
subView2.backgroundColor=[UIColor blueColor];
[scrollView addSubview:subView2];
[scrollView setContentSize:CGSizeMake(758+758, 365+365)]]
[subView2 release];
[scrollView release];

[滚动视图设置内容大小:CGSizeMake(758+758,365+365)]


您需要设置contentsize,以便能够滚动并查看所有子视图。

我尝试使用[758+758365]。现在它正在水平滚动,但我只能看到第一个视图。第二种观点不会出现

scrollView.frame=CGRectMake(0, 604, 728,365);
scrollView.bounces = YES;
scrollView.pagingEnabled = YES;
scrollView.backgroundColor = [UIColor darkGrayColor];
scrollView.delegate = self;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.userInteractionEnabled = YES;
[scrollView setContentSize:CGSizeMake(1600,365)];


UIView *subView1=[[UIView alloc]initWithFrame:CGRectMake(20, 604, 758,365)];
subView1.backgroundColor=[UIColor blueColor];
subView1.frame=scrollView.bounds;
[subView1 addSubview:myImageView];
[scrollView addSubview:subView1];


UIView *subView2=[[UIView alloc]initWithFrame:CGRectMake(828, 604, 758,365)];
subView2.backgroundColor=[UIColor blackColor];
subView2.frame=scrollView.bounds;

[scrollView addSubview:subView2];

    [subView1 release];
[subView2 release];


[scrollView release];

如果您设置了它的内容大小,我想您可以增加interfacebuilder中的滚动视图大小,给contentsize加上滚动视图,例如,如果您interfacebuilder滚动视图大小为(0,0600460),那么给view中的滚动视图内容大小是否像这样加载cgsizemake(900460)如果仍然看不到剩余的视图,那么它将工作,然后告诉meya我试过了,但仍然没有显示视图。我还通过编程尝试了scroll视图的尺寸和其中的视图,如下面的代码:scrollView.frame=CGRectMake(0604728365);scrollView.bounces=是;scrollView.PaginEnabled=是;scrollView.backgroundColor=[UIColor darkGrayColor];scrollView.delegate=self;scrollView.showsHorizontalScrollIndicator=否;scrollView.userInteractionEnabled=是;UIView*subView1=[[UIView alloc]initWithFrame:CGRectMake(20604758365)];子视图1.backgroundColor=[UIColor blueColor];[滚动视图添加子视图:子视图1];[子视图1发布];UIView*subView2=[[UIView alloc]initWithFrame:CGRectMake(828604758365)];subView2.backgroundColor=[UIColor blueColor];[滚动视图添加子视图:子视图2];[子视图2发布];[滚动视图发布];是的,老板,我已经做了,现在显示了,但它不是水平滚动,而是在diagnoll滚动。[scrollView setContentSize:CGSizeMake(758,365+365)]尝试使用这个我尝试了使用[758+758365]。现在它正在水平滚动,但我只能看到第一个视图。第二种观点不会出现