0

In my application there is one UIScrollView having UITextView.

if the UITextView has 200 lines and user will select the first line and drag the last end point of selected text and user will drag that point to select more lines.

then, in a screen whatever the text seen, the user can select but the scroll view isn't automatic scrolling to select another text line.

may be it's quite confusing to understand but i don't know exactly what to ask for this question.

for understanding i am putting image here. in image that blue colored last end point will drag down then UITextView should scroll. that functionality i want in my application.

enter image description here

any types of idea, code,link will be great help...

EDIT :

The text view is fit to 200 lines.
means the text height is that much that 200 lines of text having.
so i have to scroll the scroll view and for that need any event will call on drag down the end point.

Sam
  • 431
  • 7
  • 23
  • If you try to start selecting text from bottom to top UITextView will scroll. – Rajat Mar 28 '14 at 06:29
  • this is not the solution. i can't tell user to select the text from bottom. i need to start it as i said. have you any idea still ? – Sam Mar 28 '14 at 06:34
  • Set UITextView userInteractionEnabled = YES; UITextView.editable =NO; UITextView.scrollEnabled = YES;.. This is delegate property of uitextView to scroll with out UIScrollView... Add in your .h file... – Parvendra Singh Mar 28 '14 at 07:00
  • i can't do editable=NO. and please see my edited question. text view is in scroll view. and on dragging, i want to scroll the scrollview. – Sam Mar 28 '14 at 07:14
  • you have an UIScrollView And A UiTextView On scrollview... Why ??? – Parvendra Singh Mar 28 '14 at 07:16
  • Did You enabled TextView scrolling? – Himanshu Joshi Mar 28 '14 at 07:20
  • @HimanshuJoshi No, text view's scrolling is False. – Sam Mar 28 '14 at 07:22
  • So Enable it for scrolling behavior of textView – Himanshu Joshi Mar 28 '14 at 07:29
  • @Sam, the `UITextView` scrolls on selection automatically, unless you alter it's properties. Add the code you use to initialize your textView. Also, tell us if you change the frame/bounds of your textView. If the bounds are greater than the contentSize, it will not scroll. Again, show some code. – n00bProgrammer Mar 29 '14 at 06:26

2 Answers2

0

It may be that UIScrollView is intercepting the touch when you drag your finger over it.

For a test, I would try setting the UIScrollView userInteractionEnabled = NO, and see if that allows the auto scrolling of the UITextView.

If it does then I would make a delegate for the UITextView which for delegate method textViewDidBeginEditing sets UIScrollView userInteractionEnabled = NO;

and for delegate method textViewDidEndEditing sets UIScrollView userInteractionEnabled = YES;


similarly, for the UITextView you can try setting exclusiveTouch = YES and back to NO in the delegates, and see if that helps.

Darshan Kunjadiya
  • 3,323
  • 1
  • 29
  • 31
Cris
  • 464
  • 1
  • 3
  • 15
  • ok bro... but my application's requirement is to set text view in scroll view. text view is fit for the text. so i want when user drag the end point then scroll view will scroll. – Sam Mar 28 '14 at 06:41
  • Do you need a scroll view? what is the benefit of the scroll view? – Cris Mar 28 '14 at 07:05
  • i need scroll view. because if there is no text in text view then also it has to bounce and scroll. and also scroll view has one text field and text view. both will scroll same. so with this, do you have any idea ? if you don't have code then okay. i'll create by my self. – Sam Mar 28 '14 at 07:11
0

Write this And all the problem will resolve Bro ..... Do it

        UITextView *lblNews=[[UITextView alloc]init];
        lblNews.textColor = [UIColor blackColor];
        lblNews.userInteractionEnabled=YES;
        lblNews.scrollEnabled=YES;
        lblNews.editable=NO;
        lblNews.dataDetectorTypes = UIDataDetectorTypeAll;
        lblNews.contentInset = UIEdgeInsetsMake(20.0, 0.0, 20.0, 0.0);
       [self.view addSubView:lblNews];
Parvendra Singh
  • 965
  • 7
  • 19