문제

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.

도움이 되었습니까?

해결책

Use following code for present popoverView.

[popover presentPopoverFromRect:button.frame inView:self.scrollView permittedArrowDirections: UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionUp animated:YES];

다른 팁

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];

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top