How to change the coordinates of a hike on the fly

Background

I need to display a popover from imageview (a rectangle, not a barbutton) that has a search box. Popper must be submitted from UIModalPresentationFormSheet. This is successfully achieved.

Problem

The problem I am facing (in landscape mode) is when the keyboard is displayed, the modal shape of the sheet moves up and along with it my frame for popover.Hence popover remains in its original position (before the keyboard was shown) and the rectangle presented moves up. The solution I applied is (using presentPopoverFromRect) popover in -(void)didShowKeyBoard:(NSNotification*) notif from the changed rect and does the same in -(void)didhideKeyBoard:(NSNotification*) notif . This works fine, but the transition is very fast and resilient. So how can I achieve a smooth transition for this?

What i tried

I tried:

 [UIView beginAnimations:nil context:nil]; [UIView setAnimationCurve:UIViewAnimationCurveLinear]; [UIView setAnimationDuration:5.0f]; [_statePopover presentPopoverFromRect:stateHandler.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO]; [UIView commitAnimations]; 

but it didn’t work.

Can someone direct me to the right way to do this?
Any help is appreciated.

+6
source share
1 answer

Well, this partially solved my problem. I used submit to postpone popover presentation. This goes as follows:

 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_USEC), dispatch_get_current_queue(), ^{ [_statePopover presentPopoverFromRect:statehandler.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; }); 

This works as needed when my keyboard deviates, but the same fragment cannot provide the desired result when the keyboard is displayed.

Please leave comments if someone finds out why he is behaving this way. Thanks!

+1
source

Source: https://habr.com/ru/post/946398/


All Articles