Use following code for present popoverView.
[popover presentPopoverFromRect:button.frame inView:self.scrollView permittedArrowDirections: UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionUp animated:YES];
Question
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.
Solution
Use following code for present popoverView.
[popover presentPopoverFromRect:button.frame inView:self.scrollView permittedArrowDirections: UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionUp animated:YES];
OTHER TIPS
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.
[ur popovername presentPopoverFromRect:[(UIButton *)sender frame] inView:anchor.superview permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];