Bob Bob - 1 month ago 24
C# Question

Xamarin IOS: How to display a popup control from button click

This is for iPhone.

I have a button and when it's clicked I want to pop-up another control which covers the whole screen. This screen could have any number of controls. And I can close this screen by clicking on an x in the top right corner or programmatically inside any event on the new screen.

I could probably do this by using a UINavigationController which just brings me to a new screen and has a link back to the previous screen but I would just like to ask if there is another option?

What I am doing is I have a map which shows a users location from a pin. But if the user wants to type in a new location instead of using the pin location then they will click a button, go to a new screen, type in an address and click a "suggested" address from what they type.

Any advice would be appreciated or a link to a code sample would be great


You can't use popover for iPhone, i think that you can use Modal View.

yourButton.TouchUpInside += (object sender, EventArgs e) => 
YourController yourController = new YourController();

yourController.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
this.PresentViewController(yourController, true, null);

and to close you only need to dismiss the modal!!