[Solved] how to have UIImage below UILabel or UITextView in a scrollview


You must implement your UIScrollView and then add the desired subview (UIImageView and UILabel in your case).

In you viewDidLoad:

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scrollView.backgroundColor = [UIColor redColor];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, scrollView.frame.size.width * 2, 100)];
imageView.backgroundColor = [UIColor blueColor];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(imageView.frame.size.width, 0, imageView.frame.size.width * 2, 40)];
label.text = @"Hello World";

[self.view addSubview:scrollView];
[scrollView addSubview:imageView];
[scrollView addSubview:label];

Do not forget to set your UIScrollView‘s content size > to your frame:

scrollView setContentSize:CGSizeMake(self.view.frame.size.width * 2, self.view.frame.size.height);

This should provide you the guidance you requested.

2

solved how to have UIImage below UILabel or UITextView in a scrollview