I’m creating an iOS application, which in one of its screens, I’m using a scroll view,
I’ve two view in that screen to be scrolled “black and red” views,
But, Unfortunately, when i add them to the scroll view only on of them is displayed.
The Frame of both “red and black” views are 320 W * 460 H;
This is my code “I’ve only the black view displayed”:
-(void)viewDidLoad {
[super viewDidLoad];
scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
[scrollView setContentSize:CGSizeMake(300, 1200)];
[scrollView addSubview:redView];
[scrollView addSubview:blackView];
[self.view addSubview:scrollView];
[scrollView setBackgroundColor:[UIColor lightGrayColor]];
[scrollView setCanCancelContentTouches:NO];
scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scrollView.clipsToBounds = YES; // default is NO, we want to restrict drawing within
//our scrollview
scrollView.scrollEnabled = YES;
scrollView.pagingEnabled=YES;
}
Thanks in advance,
You don’t seem to be setting the frames for the subviews anywhere, which means their origins are both
(0, 0). The views are both there, but one is on top of the other. Set the frames to position them.