【发布时间】:2010-12-07 07:22:05
【问题描述】:
我想在我的 ipad 应用程序的 uiscrollview 中放置 uiviews 列表而不是 uiimageviews 作为内容。我使用 imageviews 滚动图像,但我需要 uiviews 作为必须水平滚动的子视图列表?我试过了通过 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];
【问题讨论】:
-
你设置了它的内容大小,我认为你增加了 interfacebuilder 中的滚动视图大小,给 contentsize 更多然后滚动视图,例如如果你 interfacebuilder 滚动视图大小是 (0,0,600,460) ,然后在 viewdid 加载中给出滚动视图内容大小,就像这样 cgsizemake(900,460) 它会起作用
-
如果仍然没有看到剩余的视图,请告诉我
-
是的,我试过这样仍然没有显示视图。我还尝试以编程方式尝试滚动视图的尺寸和其中的视图,如下面的代码:
-
scrollView.frame=CGRectMake(0, 604, 728,365); scrollView.bounces = YES; scrollView.pagingEnabled = YES; scrollView.backgroundColor = [UIColor darkGrayColor]; scrollView.delegate = 自我; scrollView.showsHorizontalScrollIndicator = NO; scrollView.userInteractionEnabled = YES;
-
UIView *subView1=[[UIView alloc]initWithFrame:CGRectMake(20, 604, 758,365)]; subView1.backgroundColor=[UIColor blueColor]; [scrollView addSubview:subView1]; [subView1 发布]; UIView *subView2=[[UIView alloc]initWithFrame:CGRectMake(828, 604, 758,365)]; subView2.backgroundColor=[UIColor blueColor]; [scrollView addSubview:subView2]; [subView2 发布]; [scrollView 发布];
标签: iphone objective-c ios4