Ios – textview inside a scrollview ios

iosiphonestoryboarduiscrollviewuitextview

I am new in IOS programming, I have a tableview, when I Select an item in the table pulls up a detail view. The detail view has title, picture, and at the bottom a textview. All those items are inside a scrollview. I want the whole page to scroll not just the text. The problem is that the textview is scrollable, so I have 2 scrolls, one for the main scroll of the view, and the second one is for the text, what I need is to combine the two scrolls, it means I want when I scroll the view, the text immediately scrolls with it.

this is a screenshot about the view:

enter image description here

and the scrolling is disabled:

enter image description here

this is after updating the height constraint

enter image description here

this is a screenshot of the scrollview properties

enter image description here

the code is:

        NSString *text =[[jsonResults objectAtIndex:0] objectForKey:@"content"];

    CGSize textSize = [text sizeWithFont:[UIFont systemFontOfSize:14]
                       constrainedToSize:CGSizeMake(300, 5000) lineBreakMode:NSLineBreakByCharWrapping];

    [self.detailTextView setFrame:CGRectMake(self.detailTextView.frame.origin.x,self.detailTextView.frame.origin.y,textSize.width,textSize.height)];

    [self.detailTextView setText:text];
scroll.ContentSize=CGSizeMake(320,1000);

Thank You alot,

Best Solution

try like this,

In your case do one this set the textview frame dynamically based on the text and disable the scrolling of textView .and add textview to scrollview.

enter image description here

deselect scrolling Enabled of the textview.

Related Question