开发者

how to scroll the scrollview after inserting textview?

开发者 https://www.devze.com 2023-03-14 06:37 出处:网络
I\'ve a problem that I want to insert m开发者_C百科any lines in my scrollview from a textview but I want that after inserting 6 lines the scroll will be enabled not before it. please some one help me.

I've a problem that I want to insert m开发者_C百科any lines in my scrollview from a textview but I want that after inserting 6 lines the scroll will be enabled not before it. please some one help me..


Initially set the scrollEnabled property of the scrollView to NO, and set it to YES after inserting those six lines.


You will have to put a condition according to the number of characters. Roughly determine the number of characters in six lines. Store the textView text in a string and use the following condition:

NSString *textString = myTextField.text;

    if ( [textString length] < NUMBER_OF_CHARACTERS_IN_SIX_LINES )
    {

    [myScrollView setScrollEnabled:NO];

    }

    else

    [myScrollView setScrollEnabled:YES];


You shoud set the scrollView's contentSize accordingly.

Assuming it's a vertical scroll, find the height of text/ scrollView and set it like this:

scrollView.contentSize = CGSizeMake(newHeight,width);
0

精彩评论

暂无评论...
验证码 换一张
取 消