1

我的滚动视图有问题!我有一个名为 Rootview 的视图,我想将三个子视图添加到滚动视图中。当我将滚动视图添加为子视图时,中间视图和三个子视图消失了。这是我的代码.. Rootview(整个窗口)和滚动视图是出口。

UIView *middleView = [[UIView alloc] initWithFrame:CGRectMake(0, 218, 2024, 218)];
[middleView setBackgroundColor: [UIColor yellowColor]];
[RootView addSubview:middleView];

//create new views for sap systems beginning from left

UIView *firstSystem1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 218)];
[firstSystem1 setBackgroundColor: [UIColor grayColor]];
[middleView addSubview:firstSystem1];

UIView *secondSystem1 = [[UIView alloc] initWithFrame:CGRectMake(305, 0, 300, 218)];
[secondSystem1 setBackgroundColor: [UIColor grayColor]];
[middleView addSubview:secondSystem1];

UIView *thirdSystem1 = [[UIView alloc] initWithFrame:CGRectMake(610, 0, 300, 218)];
[thirdSystem1 setBackgroundColor: [UIColor grayColor]];
[middleView addSubview:thirdSystem1];




CGSize scrollViewContentSize1 = CGSizeMake(2024, 218);

 [middleScrollView setContentSize:scrollViewContentSize1];
[middleScrollView addSubview:middleView];

任何人都可以帮助我吗?

4

1 回答 1

0

问题是你没有在middleScrollView任何地方添加你的

改变这个

[RootView addSubview:middleView];

为了这

[RootView addSubview:middleScrollView];
于 2012-12-27T14:20:02.617 回答