kxmenu icon indicating copy to clipboard operation
kxmenu copied to clipboard

Not positioning correctly in UIScrollView when using negative contentOffset (e.g. pull-to-refresh)

Open koloritcm opened this issue 12 years ago • 3 comments

Here https://github.com/kolyvan/kxmenu/blob/master/Source/KxMenu.m#L323 KxMenuOverlay *overlay = [[KxMenuOverlay alloc] initWithFrame:view.bounds];

view.bounds has y negative during pull-to-refresh and therefore the menu is shown the height of the pull-to-refresh area too high. Its correct in that way that it covers the whole screen with the overlay so you can click everywhere to dismiss, but the actual menu will be displaced.

The solution if you don't care that the pull-to-refresh area will not be part of the dismiss area is this instead:

``KxMenuOverlay *overlay = [[KxMenuOverlay alloc] initWithFrame:CGRectMake(0, 0, view.frame.size.width, view.frame.size.height)];`

Or if you want the whole area to be dismiss area you can adjust the supplied rect for contentOffset (here: https://github.com/kolyvan/kxmenu/blob/master/Source/KxMenu.m#L316):

if([view isKindOfClass:[UIScrollView class]]) rect = CGRectMake(rect.origin.x, rect.origin.y-((UIScrollView*)view).contentOffset.y, rect.size.width, rect.size.height);

koloritcm avatar Jun 04 '13 16:06 koloritcm

HI, thanks for your proposal.

First, this code

KxMenuOverlay *overlay = [[KxMenuOverlay alloc] initWithFrame:CGRectMake(0, 0, view.frame.size.width, view.frame.size.height)];

will not work correct in landscape mode.

For if([view isKindOfClass:[UIScrollView class]]), imho, the better solution for avoid problem with scroll view: use a superview of scrollview for showing kxmenu.

kolyvan avatar Jun 06 '13 04:06 kolyvan

@kolyvan Why is it different in landscape mode? How could you use a superview of UIScrollView if you want to be able to scroll?

koloritcm avatar Jun 08 '13 10:06 koloritcm

thanks

longzihang avatar Jul 05 '13 02:07 longzihang