Xamarin iOS: how to display pop-up control with click button

This is for iPhone.

I have a button, and when she clicked, I want to pop up another control that spans the entire screen. There can be any number of controls on this screen. And I can close this screen by clicking on x in the upper right corner or programmatically inside any event on a new screen.

I could do this using the UINavigationController, which just takes me to a new screen and has a link to the previous screen, but I just wanted to ask if there is another option?

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

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

+4
source share
2 answers

You cannot use popover for iPhone, I think 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 for closing you only need to abandon the modal.

+8
source

If this is an iPad app, you can use the UIPopoverController .

// myvc is an instance of the view controller you want to display in the popup
UIPopoverController pop = new UIPopoverController(myvc);

// target is another view that the popover will be "anchored" to
pop.PresentFromRect(target.Bounds, target, UIPopoverArrowDirection.Any, true);

iPhone, UIPopoverController. , UIAlertView ( iPhone iPad).

UIAlertView alert = new UIAlertView();
alert.Title = "Title";
alert.AddButton("OK");
alert.Message = "Please Enter a Value.";
alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
alert.Clicked += (object s, UIButtonEventArgs ev) => {
  // handle click event here
  // user input will be in alert.GetTextField(0).Text;
};

alert.Show();
+8

Source: https://habr.com/ru/post/1542255/


All Articles