I have a scrollview which contains a view and 3 subviews inside of this view (topview, textview and bottomview). See the view's hierachy below. The scrollview is scrollable only if I scroll it from the textview but not from any other area. What am I doing wrong? All views have user interaction enabled.
EDIT: I have realized if User Interaction is disabled in the containerview I can scroll from any place in the view but since I have buttons inside my container view I want user interaction and scrolling, is that possible?
This is the code:
- (void)viewDidLoad
{
[super viewDidLoad];
//update labels and images with info
self.TitleLabel.text = game.title;
self.SubtitleLabel.text = game.developer;
self.DescriptionTextView.text = game.description;
self.Screenshot.image = [[UIImage alloc] initWithData:game.pictData];
}
-(void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.mainScrollView setScrollEnabled:YES];
[self.mainScrollView setContentSize:CGSizeMake(320, 1200)];
}
-(void)viewDidLayoutSubviews
{
NSAttributedString * string = [[NSAttributedString alloc] initWithString:self.game.description];
CGFloat heightTV = [self textViewHeightForAttributedText:string andWidth:260];
self.dynamicTVHeight.constant = heightTV;
self.dynamicContainerHeight.constant = self.topView.frame.size.height + heightTV + self.bottomView.frame.size.height+100;
NSLog(@"height container %f", self.dynamicContainerHeight.constant);
[self.view layoutIfNeeded];
}
- (CGFloat)textViewHeightForAttributedText:(NSAttributedString *)text andWidth:(CGFloat)width
{
UITextView *textView = [[UITextView alloc] init];
[textView setAttributedText:text];
CGSize size = [textView sizeThatFits:CGSizeMake(width, FLT_MAX)];
return size.height;
}