0

我在其他控制器中创建了一个带有一些标签的自定义 UIView。我已将 UIView 命名为“ReportsView.h”

然后回到主控制器 UIView,我希望在 UIScrollView 中添加一个子视图。使用下面的代码,添加了视图,但内容为空白。这就像添加一个纯空白的 UIView 而不是我准备好的 ReportsView。

ReportsView *rv = [[ReportsView alloc] init];
[rv setFrame:CGRectMake(self.scrollView.frame.size.width,0,self.scrollView.frame.size.width,600)];
[self.scrollView addSubview:rv];
4

1 回答 1

1
CGRectMake(self.scrollView.frame.size.width,0,self.scrollView.frame.size.width,600)

被放置在屏幕外。(或滚动视图正在剪切子视图)

我相信在你的情况下,滚动视图的子视图的起源应该是 0,0

CGRectMake(0,0,self.scrollView.frame.size.width,600)

或者

CGRectMake(0,0,self.scrollView.frame.size.width,self.scrollView.frame.size.height)

应该管用

于 2012-12-13T15:13:10.073 回答