how to scroll the scrollview after inserting textview?
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);
精彩评论