kolyvan / kxmenu

KxMenu is a vertical popup menu for using in iOS applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

koloritcm opened this issue · 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);

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 Why is it different in landscape mode? How could you use a superview of UIScrollView if you want to be able to scroll?

thanks