In this code example, i am trying to produce the following view hierarchy
Window -> background image -> scroll view -> text view
All i see however is
Window -> background image
What am i missing please?
-(void) viewWillAppear:(BOOL)animated {
UIScrollView *scrollWindow = [[UIScrollView alloc]
initWithFrame:CGRectMake(30, 30, 440, 212)];
UITextView *scrollableText = [[UITextView alloc] init];
[scrollableText setEditable:NO];
[scrollableText setText:@"Why, hello there"];
[scrollWindow addSubview:scrollableText];
UIImage *backgroundImage = [[UIImage alloc] initWithCGImage:
[UIImage imageNamed:@"about_bg.png"].CGImage];
UIImageView *backgroundView = [[UIImageView alloc]
initWithImage:backgroundImage];
[backgroundView addSubview:scrollWindow];
[[self view] addSubview:backgroundView];
}
Andrew is right about not making the scroll view a subview of the background
UIImageViewview. But the scroll view is invisible. Only its content (scrollableText) will show. And you haven’t setscrollableText‘s frame, so it’s effectively invisible too. Init like so:And you should see it.