Domanda

So I have this UIButton, when clicked it triggers a UIPopOverController.

The UIButton is located in a Bar Button Item, in a Toolbar that has a 960 value for y. An iPad view.

My problem is, this button shows the PopOver at the top of the screen, whilst another button on the same toolbar shows the PopOver correctly (direction up).

I tried forcing the direction and changing buttons location on the toolbar but it didn't work. I tried the frame value for the toolbar but that brings it only from the middle. Here is the code for button action.

[self.popOverController setContentViewController:self.legendViewController];

[_popOverController presentPopoverFromRect:self.btnLegend.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES ];

I know that there could be a few functional ways of doing this. I am starting to think that this specific UIButton is cursed.

È stato utile?

Soluzione

You should try the bar button presentation method.

When using presentPopoverFromRect:inView: the frame provided would usually be your button (as you have it) but the view would be the button superview (not the root view). This is because the frame needs to amen something in the coordinate space of the provided view.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top