Wrong position of popover in scrollview iOS

1.2k views Asked by At

I have a button that will show the popover. The popover must appear under the button. But it appears somewhere on the screen.

Here's My Code for the popover

UIView *popoverView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320,340)]; 
[popoverView addSubview:tblViewMenu];
popoverContent.view = popoverView;
popoverContent .contentSizeForViewInPopover = CGSizeMake(620,620);
popPickerController = [[UIPopoverController alloc]initWithContentViewController:popoverContent];
[popPickerController presentPopoverFromRect:anchor.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUpanimated:YES];

BTW this popover will show inside a scrollview.

3

There are 3 answers

0
iPatel On BEST ANSWER

Use following code for present popoverView.

[popover presentPopoverFromRect:button.frame inView:self.scrollView permittedArrowDirections: UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionUp animated:YES];
0
βhargavḯ On

Give immediate parent of button as parameter value inView:

[popPickerController presentPopoverFromRect:anchor.frame
                                     inView:anchor.superview
                   permittedArrowDirections:UIPopoverArrowDirectionUp
                                   animated:YES];

Always make sure to give right parent while presenting popover.

0
Sowji On

[ur popovername presentPopoverFromRect:[(UIButton *)sender frame] inView:anchor.superview permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];