0

I have an issue with scroll view. I have implemnted two font resize buttons to increase or decrease text font size for the text view embedded in the scroll view. But after decreasing font size, I calculate the scroll view content and reize it to adapt to the new text view height. But every time I modify text font, it scrolls down for every step.

Here is the code:

- (IBAction)decreaseText:(id)sender {

    int MyTextSizeMin = 8;
    int MyTextSizeMax = 20;

    // disable buttons when they're out of the range.
    BOOL smallerEnabled = textFontSize > MyTextSizeMin;
    BOOL biggerEnabled = textFontSize < MyTextSizeMax;
    [self.decreaseText setEnabled:smallerEnabled];
    [self.increaseText setEnabled:biggerEnabled];


    height =0;

    CGFloat secondLabelsize = texto.font.pointSize;

    [texto setFont:[UIFont systemFontOfSize:(secondLabelsize-1)]];

    CGRect frame = texto.frame;

    frame.size.height = texto.contentSize.height;

    self.texto.frame = frame;

    height +=texto.contentSize.height;

    height += self.imagen.image.size.height;

    height += self.fecha.frame.size.height;

    height += self.titulo.frame.size.height;

    height += 200;

    self.scrollView.contentSize=CGSizeMake(300.0,height);

    [self.scrollView setNeedsDisplay];


}

How can I disable this undesired scroll?

Many thanks!

1 Answer 1

1

Try it may it help full for you.

[scrollView scrollRectToVisible:CGRect animated:BOOL];
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.