Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I move FPPopover as low as I want? If I push it too low, it jumps back to the top

I'm using FPPopover to present a pop over view for my iPhone app. I'm having an issue, however, where when I present it, it will only allow me to present it so low or it will jump to the top. And this is well before it gets cut off anyway.

For example:

[self.speedOptionsPopover presentPopoverFromPoint:CGPointMake(0, 235)];

Works fine, but if I put it a 255 instead of 235 (as it's a good 40px from the bottom) it jumps back up to the top.

Does anyone have any experience with this or how I could fix it?

Also, bonus points if you can explain why the content for the popover always starts like 50px from the top, when I want it to start up higher. How can I change this also?

More code from the creation:

- (void)speedOptionsTapped:(UIBarButtonItem *)sender {
    // Set the delegate in the controller that acts as the popover's view to be self so that the controls on the popover can manipulate the WPM and number of words shown
    self.speedOptionsController.delegate = self;

    self.speedOptionsPopover.arrowDirection = FPPopoverNoArrow;
    self.speedOptionsPopover.border = NO;
    self.speedOptionsPopover.contentSize = CGSizeMake(320, 190);
    [self.speedOptionsPopover presentPopoverFromPoint:CGPointMake(0, 235)];
}
like image 397
Doug Smith Avatar asked May 12 '13 23:05

Doug Smith


1 Answers

Try replacing this part of the code in FPPopoverController.m:

//ok, will be vertical
if(ht == best_h || self.arrowDirection == FPPopoverArrowDirectionDown)

with this code:

//ok, will be vertical
if (self.arrowDirection == FPPopoverNoArrow)
{
   r.origin.x = p.x;
   r.origin.y = p.y;
}
else if(ht == best_h || self.arrowDirection == FPPopoverArrowDirectionDown)

The reason you might be having this issue is that the macro FPPopoverArrowDirectionIsVertical considers a popover with no arrows as having a vertical arrow. So, the result is that is tries to best position your popover as close as possible to the view that triggered the popover.

If you replace the code as indicated above, you'll be creating a special case for popovers with no arrows and asking that the original points be respected without repositioning.

like image 94
km3h Avatar answered Nov 13 '22 09:11

km3h