Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextView inside a UIScrollView inside a Popover is not fully visible when keyboard is displayed

I have a UIPopover with a UIScrollViewinside it that contains a UITextView at the bottom. When the keyboard shows, the popover is resized as the text view begins to be edited. I want the code below to ensure the text view is visible:

- (void)textViewDidBeginEditing:(UITextView *)textView {

    CGRect visRect = textView.frame;
    [self.scrollView scrollRectToVisible:visRect animated:NO];

}

The problem is that the code does not make the entire text view visible. Instead, only the text view up to the bottom of the cursor is shown, as shown below:

enter image description here

How can I show the entire text view/ scroll the scrollview to the bottom? I have tried this:

CGPoint bottomOffset = CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.bounds.size.height);
[self.scrollView setContentOffset:bottomOffset animated:YES];

as explained in this answer but nothing works.

In addition, my scrollview is scrolled to the position shown AFTER the keyboard is moved into place. Ideally I'd like the scrolling to happen before or during the keyboard movement.

Any help would be great.

like image 691
Dave Chambers Avatar asked Nov 03 '22 22:11

Dave Chambers


1 Answers

@hey Dave

This By default Case in of UIPopOverController, whenever we used UIPopOverControler to display any PopUpView and in suppose that PopUpView height as large as can be covered by KeyBoard then in that case that PopOverView Automatically gets Shrink itself.as you resign keyboard that PopUpView will expand itself automatically.I have faced same case.

This is just my opinion , you can change the origin of CurrentView(parentView of PopUpView) as keyboard going to display/hide so that PopUpView could display itself properly from and could get the appropriate space.

See Below Are the Delegate methods of UITextView Responds Back as editing start and end.

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
 //chnage the OriginY of PopUpView's SUperView
}
- (void)textViewDidBeginEditing:(UITextView *)textView
{  
 //re Adjust the OriginY of PopUpView's SUperView
}

I hope it may helpful to you.

like image 171
Kamar Shad Avatar answered Nov 15 '22 12:11

Kamar Shad